mirror of
https://github.com/eclipse/paho.mqtt.android.git
synced 2025-05-08 18:39:31 +08:00
fix cancel() called with a null PendingIntent
In case no connection can be established, AlarmPingSender stop method will be called when it has not been started yet. `java.lang.NullPointerException: cancel() called with a null PendingIntent` will be thrown as the pending intent has not been setup yet.
This commit is contained in:
parent
7459017f3e
commit
adffd9391c
@ -81,13 +81,13 @@ class AlarmPingSender implements MqttPingSender {
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
// Cancel Alarm.
|
||||
AlarmManager alarmManager = (AlarmManager) service
|
||||
.getSystemService(Service.ALARM_SERVICE);
|
||||
alarmManager.cancel(pendingIntent);
|
||||
|
||||
Log.d(TAG, "Unregister alarmreceiver to MqttService"+comms.getClient().getClientId());
|
||||
if(hasStarted){
|
||||
// Cancel Alarm.
|
||||
AlarmManager alarmManager = (AlarmManager) service.getSystemService(Service.ALARM_SERVICE);
|
||||
alarmManager.cancel(pendingIntent);
|
||||
|
||||
hasStarted = false;
|
||||
try{
|
||||
service.unregisterReceiver(alarmReceiver);
|
||||
|
Loading…
x
Reference in New Issue
Block a user