From 8b434e041cbdec4251d97bd548e563a53a6e75e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Mon, 16 Jan 2017 10:17:25 +0100 Subject: [PATCH] Dont crash if color has wrong format --- src/android/BackgroundMode.java | 9 +++------ src/android/ForegroundService.java | 10 ++-------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/android/BackgroundMode.java b/src/android/BackgroundMode.java index 43557e7..a57cfaf 100644 --- a/src/android/BackgroundMode.java +++ b/src/android/BackgroundMode.java @@ -87,8 +87,7 @@ public class BackgroundMode extends CordovaPlugin { * @param callback The callback context used when * calling back into JavaScript. * - * @return - * Returning false results in a "MethodNotFound" error. + * @return Returning false results in a "MethodNotFound" error. * * @throws JSONException */ @@ -131,8 +130,7 @@ public class BackgroundMode extends CordovaPlugin { /** * Called when the system is about to start resuming a previous activity. * - * @param multitasking - * Flag indicating if multitasking is turned on for app + * @param multitasking Flag indicating if multitasking is turned on for app. */ @Override public void onPause(boolean multitasking) { @@ -144,8 +142,7 @@ public class BackgroundMode extends CordovaPlugin { /** * Called when the activity will start interacting with the user. * - * @param multitasking - * Flag indicating if multitasking is turned on for app + * @param multitasking Flag indicating if multitasking is turned on for app. */ @Override public void onResume(boolean multitasking) { diff --git a/src/android/ForegroundService.java b/src/android/ForegroundService.java index f68b500..f674fdd 100644 --- a/src/android/ForegroundService.java +++ b/src/android/ForegroundService.java @@ -35,7 +35,6 @@ import android.os.PowerManager; import org.json.JSONObject; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** @@ -251,18 +250,13 @@ public class ForegroundService extends Service { if (Build.VERSION.SDK_INT < 21 || hex == null) return; - int aRGB = Integer.parseInt(hex, 16) + 0xFF000000; - try { + int aRGB = Integer.parseInt(hex, 16) + 0xFF000000; Method setColorMethod = notification.getClass().getMethod( "setColor", int.class); setColorMethod.invoke(notification, aRGB); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (Exception e) { e.printStackTrace(); } }