Fix service notification channel for older Android versions (prior to Oreo)
This commit is contained in:
parent
93e8882433
commit
3a9729de06
2 changed files with 10 additions and 7 deletions
|
@ -7,6 +7,7 @@ import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
@ -53,11 +54,13 @@ public class LbrynetService extends PythonService {
|
||||||
|
|
||||||
NotificationManager notificationManager =
|
NotificationManager notificationManager =
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
NotificationChannel channel = new NotificationChannel(
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
NOTIFICATION_CHANNEL_ID, "LBRY Browser", NotificationManager.IMPORTANCE_LOW);
|
NotificationChannel channel = new NotificationChannel(
|
||||||
channel.setDescription("LBRY service notification channel");
|
NOTIFICATION_CHANNEL_ID, "LBRY Browser", NotificationManager.IMPORTANCE_LOW);
|
||||||
channel.setShowBadge(false);
|
channel.setDescription("LBRY service notification channel");
|
||||||
notificationManager.createNotificationChannel(channel);
|
channel.setShowBadge(false);
|
||||||
|
notificationManager.createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
Intent contextIntent = new Intent(context, MainActivity.class);
|
Intent contextIntent = new Intent(context, MainActivity.class);
|
||||||
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
|
@ -81,8 +81,8 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
|
||||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, GROUP_ID, intent, 0);
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, GROUP_ID, intent, 0);
|
||||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID);
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID);
|
||||||
builder.setContentTitle("Active downloads")
|
builder.setContentTitle("Active LBRY downloads")
|
||||||
.setContentText("Active downloads")
|
.setContentText("Active LBRY downloads")
|
||||||
.setSmallIcon(android.R.drawable.stat_sys_download)
|
.setSmallIcon(android.R.drawable.stat_sys_download)
|
||||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||||
.setGroup(GROUP_DOWNLOADS)
|
.setGroup(GROUP_DOWNLOADS)
|
||||||
|
|
Loading…
Reference in a new issue