From 74f2b8c1c2c8c5363cbd597ef7af31770bc6c1dd Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Fri, 3 Apr 2015 22:39:25 +0200 Subject: [PATCH] fix crash on some devices when creating a test notification in debug menu --- .../gadgetbridge/BluetoothCommunicationService.java | 9 +++++++-- .../freeyourgadget/gadgetbridge/DebugActivity.java | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java index 8407cbe49..71ba8054a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java @@ -209,7 +209,13 @@ public class BluetoothCommunicationService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { + if (intent == null) { + Log.i(TAG, "no intent"); + return START_NOT_STICKY; + } + String action = intent.getAction(); + if (action == null) { Log.i(TAG, "no action"); return START_NOT_STICKY; @@ -260,8 +266,7 @@ public class BluetoothCommunicationService extends Service { deviceType = GBDevice.Type.MIBAND; mGBDeviceProtocol = new MibandProtocol(); mGBDeviceIoThread = new MibandIoThread(btDeviceAddress); - } - else if (btDevice.getName().indexOf("Pebble") == 0) { + } else if (btDevice.getName().indexOf("Pebble") == 0) { deviceType = GBDevice.Type.PEBBLE; mGBDeviceProtocol = new PebbleProtocol(); mGBDeviceIoThread = new PebbleIoThread(btDeviceAddress); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DebugActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DebugActivity.java index 84f70cae9..057e35e0d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DebugActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/DebugActivity.java @@ -151,7 +151,7 @@ public class DebugActivity extends Activity { ncomp.setContentTitle("Test Notification"); ncomp.setContentText("This is a Test Notification from Gadgetbridge"); ncomp.setTicker("This is a Test Notification from Gadgetbridge"); - ncomp.setSmallIcon(R.drawable.ic_launcher); + ncomp.setSmallIcon(R.drawable.ic_notification); ncomp.setAutoCancel(true); nManager.notify((int) System.currentTimeMillis(), ncomp.build()); }