diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java index 3fd608475f..74f0577bb5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java @@ -9,6 +9,7 @@ import android.os.HandlerThread; import android.os.IBinder; import android.os.PowerManager; +import com.crashlytics.android.Crashlytics; import com.google.common.base.Charsets; import com.google.common.hash.Hashing; import com.j256.ormlite.dao.CloseableIterator; @@ -352,7 +353,13 @@ public class NSClientService extends Service { public void call(final Object... args) { if (Config.detailedLog) MainApp.bus().post(new EventNSClientNewLog("ALARM", "received")); - JSONObject data = (JSONObject) args[0]; + JSONObject data; + try { + data = (JSONObject) args[0]; + } catch (ClassCastException e) { + Crashlytics.log("Wrong alarm from NS: " + args[0]); + return; + } BroadcastAlarm.handleAlarm(data, getApplicationContext()); log.debug(data.toString()); }