mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2024-11-15 03:54:54 +00:00
Dont crash if color has wrong format
This commit is contained in:
parent
337e39b2db
commit
8b434e041c
@ -87,8 +87,7 @@ public class BackgroundMode extends CordovaPlugin {
|
|||||||
* @param callback The callback context used when
|
* @param callback The callback context used when
|
||||||
* calling back into JavaScript.
|
* calling back into JavaScript.
|
||||||
*
|
*
|
||||||
* @return
|
* @return Returning false results in a "MethodNotFound" error.
|
||||||
* Returning false results in a "MethodNotFound" error.
|
|
||||||
*
|
*
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
@ -131,8 +130,7 @@ public class BackgroundMode extends CordovaPlugin {
|
|||||||
/**
|
/**
|
||||||
* Called when the system is about to start resuming a previous activity.
|
* Called when the system is about to start resuming a previous activity.
|
||||||
*
|
*
|
||||||
* @param multitasking
|
* @param multitasking Flag indicating if multitasking is turned on for app.
|
||||||
* Flag indicating if multitasking is turned on for app
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPause(boolean multitasking) {
|
public void onPause(boolean multitasking) {
|
||||||
@ -144,8 +142,7 @@ public class BackgroundMode extends CordovaPlugin {
|
|||||||
/**
|
/**
|
||||||
* Called when the activity will start interacting with the user.
|
* Called when the activity will start interacting with the user.
|
||||||
*
|
*
|
||||||
* @param multitasking
|
* @param multitasking Flag indicating if multitasking is turned on for app.
|
||||||
* Flag indicating if multitasking is turned on for app
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onResume(boolean multitasking) {
|
public void onResume(boolean multitasking) {
|
||||||
|
@ -35,7 +35,6 @@ import android.os.PowerManager;
|
|||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -251,18 +250,13 @@ public class ForegroundService extends Service {
|
|||||||
if (Build.VERSION.SDK_INT < 21 || hex == null)
|
if (Build.VERSION.SDK_INT < 21 || hex == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int aRGB = Integer.parseInt(hex, 16) + 0xFF000000;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
int aRGB = Integer.parseInt(hex, 16) + 0xFF000000;
|
||||||
Method setColorMethod = notification.getClass().getMethod(
|
Method setColorMethod = notification.getClass().getMethod(
|
||||||
"setColor", int.class);
|
"setColor", int.class);
|
||||||
|
|
||||||
setColorMethod.invoke(notification, aRGB);
|
setColorMethod.invoke(notification, aRGB);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user