diff --git a/org.eclipse.paho.android.sample/src/main/java/org/eclipse/paho/android/sample/activity/Notify.java b/org.eclipse.paho.android.sample/src/main/java/org/eclipse/paho/android/sample/activity/Notify.java index 353372801..a52a86951 100755 --- a/org.eclipse.paho.android.sample/src/main/java/org/eclipse/paho/android/sample/activity/Notify.java +++ b/org.eclipse.paho.android.sample/src/main/java/org/eclipse/paho/android/sample/activity/Notify.java @@ -52,9 +52,14 @@ static void notifcation(Context context, String messageString, Intent intent, in //the message that will be displayed as the ticker String ticker = contentTitle + " " + messageString; + int retryFlags = PendingIntent.FLAG_UPDATE_CURRENT; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + retryFlags |= PendingIntent.FLAG_IMMUTABLE; + } + //build the pending intent that will start the appropriate activity PendingIntent pendingIntent = PendingIntent.getActivity(context, - 0, intent, 0); + 0, intent, retryFlags); //build the notification Builder notificationCompat = new Builder(context); diff --git a/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/AlarmPingSender.java b/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/AlarmPingSender.java index 8ad9569f9..f67bc2a3a 100755 --- a/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/AlarmPingSender.java +++ b/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/AlarmPingSender.java @@ -73,8 +73,13 @@ public void start() { Log.d(TAG, "Register alarmreceiver to MqttService"+ action); service.registerReceiver(alarmReceiver, new IntentFilter(action)); + int retryFlags = PendingIntent.FLAG_UPDATE_CURRENT; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + retryFlags |= PendingIntent.FLAG_IMMUTABLE; + } + pendingIntent = PendingIntent.getBroadcast(service, 0, new Intent( - action), PendingIntent.FLAG_UPDATE_CURRENT); + action), retryFlags); schedule(comms.getKeepAlive()); hasStarted = true;