|
@@ -6,6 +6,7 @@ import android.app.NotificationManager;
|
|
import android.app.PendingIntent;
|
|
import android.app.PendingIntent;
|
|
import android.app.Service;
|
|
import android.app.Service;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
+import android.content.pm.ServiceInfo;
|
|
import android.graphics.BitmapFactory;
|
|
import android.graphics.BitmapFactory;
|
|
import android.os.Build;
|
|
import android.os.Build;
|
|
import android.os.IBinder;
|
|
import android.os.IBinder;
|
|
@@ -96,7 +97,15 @@ public class AgoraForegroundService extends Service {
|
|
// Build the notification.
|
|
// Build the notification.
|
|
Notification notification = builder.build();
|
|
Notification notification = builder.build();
|
|
// Start foreground service.
|
|
// Start foreground service.
|
|
- startForeground(1, notification);
|
|
|
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){
|
|
|
|
+ int serviceTypes = ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE |
|
|
|
|
+ ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA |
|
|
|
|
+ ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK;
|
|
|
|
+ startForeground(1, notification,serviceTypes);
|
|
|
|
+ } else {
|
|
|
|
+ startForeground(1, notification);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private void stopForegroundService() {
|
|
private void stopForegroundService() {
|