triniwiz / nativescript-webrtc

Apache License 2.0
42 stars 25 forks source link

android screen share #50

Open RobinKamps opened 4 years ago

RobinKamps commented 4 years ago

First: thank you very much for your effort you put into this project.

On android screen share i get an error: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION.

It boils down that the manifest needs: <service android:name=".service.DisplayRecorderService" android:foregroundServiceType="mediaProjection"/> in the application section.

From minSdkVersion 28 on <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/ is required.

However even when using the above i get the same error. Perhaps it happens because this is not implemented in https://github.com/triniwiz/fancy-webrtc-android/blob/master/fancywebrtc/src/main/AndroidManifest.xml

This info found on StackOverflow could also be useful:

Make sure you call startForeground() before getMediaProjection()!

The best solution is to call startForeground() from onCreate() without any conditions,
 displaying some sort of default messages in notification.
 Then you can execute your logic and call NotificationManager.notify() with updated notification at any time.
triniwiz commented 4 years ago

Will check this out