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..e6d4898e9 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,14 @@ public void start() { Log.d(TAG, "Register alarmreceiver to MqttService"+ action); service.registerReceiver(alarmReceiver, new IntentFilter(action)); - pendingIntent = PendingIntent.getBroadcast(service, 0, new Intent( - action), PendingIntent.FLAG_UPDATE_CURRENT); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { + pendingIntent = PendingIntent.getBroadcast(service, 0, new Intent( + action), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); + } else { + pendingIntent = PendingIntent.getBroadcast(service, 0, new Intent( + action), PendingIntent.FLAG_UPDATE_CURRENT); + } + schedule(comms.getKeepAlive()); hasStarted = true;