diff --git a/app/src/main/java/com/kamwithk/ankiconnectandroid/Service.java b/app/src/main/java/com/kamwithk/ankiconnectandroid/Service.java index c60799d..561bb5c 100644 --- a/app/src/main/java/com/kamwithk/ankiconnectandroid/Service.java +++ b/app/src/main/java/com/kamwithk/ankiconnectandroid/Service.java @@ -33,7 +33,12 @@ public void onCreate() { // Only one time public int onStartCommand(Intent intent, int flags, int startId) { // Every time start is called Log.w("onStartCommand", "onStartCommand"); Intent notificationIntent = new Intent(this, MainActivity.class); - PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent pendingIntent = null; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { + pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); + } else { + pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); + } Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID) .setContentTitle("Ankiconnect Android")