mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-11-19 02:29:25 +01:00
Fix notification compatibility for API 26 and higher
This commit is contained in:
parent
e0dc7f5b40
commit
21c2f51ea6
@ -75,7 +75,16 @@ public class ForegroundServiceContext extends ContextWrapper {
|
|||||||
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mIntent, 0);
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, mIntent, 0);
|
||||||
|
|
||||||
return new NotificationCompat.Builder(context, "foreground-service")
|
String notificationChannelID = "foreground-service";
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
NotificationChannel channel = new NotificationChannel(notificationChannelID, context.getResources().getString(R.string.notification_service_name), NotificationManager.IMPORTANCE_MIN);
|
||||||
|
channel.setShowBadge(false);
|
||||||
|
channel.setLockscreenVisibility(0);
|
||||||
|
channel.setVibrationPattern(new long[0]);
|
||||||
|
context.getSystemService(NotificationManager.class).createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
return new NotificationCompat.Builder(context, notificationChannelID)
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
.setContentTitle(context.getResources().getString(R.string.notification_service_title))
|
.setContentTitle(context.getResources().getString(R.string.notification_service_title))
|
||||||
|
Loading…
Reference in New Issue
Block a user