Dont crash if color has wrong format

This commit is contained in:
Sebastián Katzer 2017-01-16 10:17:25 +01:00
parent 337e39b2db
commit 8b434e041c
2 changed files with 5 additions and 14 deletions

View File

@ -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) {

View File

@ -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();
}
}