mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2025-12-15 19:03:31 +00:00
Added extra settings for Lollipop devices
Two settings have been added: - Notification visibility - allows the notification to be made visible on a secure lock screen - Color - used to set the color of the notification circle that contains the icon
This commit is contained in:
@@ -33,6 +33,7 @@ import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@@ -141,6 +142,20 @@ public class ForegroundService extends Service {
|
||||
.setOngoing(true)
|
||||
.setSmallIcon(getIconResId());
|
||||
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if(settings.optBoolean("isPublic") == true) {
|
||||
notification.setVisibility(Notification.VISIBILITY_PUBLIC);
|
||||
}
|
||||
|
||||
if(!settings.optString("color").equals("")) {
|
||||
try {
|
||||
notification.setColor(Color.parseColor(settings.optString("color")));
|
||||
} catch (Exception e) {
|
||||
Log.e("BackgroundMode", settings.optString("color") + " is not a valid color");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (intent != null && settings.optBoolean("resume")) {
|
||||
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(
|
||||
|
||||
Reference in New Issue
Block a user