diff --git a/Examples/simple-fcm-client/android/app/src/main/AndroidManifest.xml b/Examples/simple-fcm-client/android/app/src/main/AndroidManifest.xml index a0aba2877e579add45e89a746d888fbc3fe2d924..869cb8fefd4c80722074ea7936798c78034b9cd6 100644 --- a/Examples/simple-fcm-client/android/app/src/main/AndroidManifest.xml +++ b/Examples/simple-fcm-client/android/app/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ + { private SharedPreferences sharedPreferences; private Boolean mIsForeground; - public SendNotificationTask(Context context, SharedPreferences sharedPreferences, Boolean mIsForeground, Bundle bundle){ + SendNotificationTask(Context context, SharedPreferences sharedPreferences, Boolean mIsForeground, Bundle bundle){ this.mContext = context; this.bundle = bundle; this.sharedPreferences = sharedPreferences; @@ -215,6 +216,16 @@ public class SendNotificationTask extends AsyncTask { NotificationManagerCompat.from(mContext).notify(notificationID, info); } + + if(bundle.getBoolean("wake_screen", false)){ + PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE); + if(pm != null && !pm.isScreenOn()) + { + PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK |PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.ON_AFTER_RELEASE,"FCMLock"); + wl.acquire(5000); + } + } + //clear out one time scheduled notification once fired if(!bundle.containsKey("repeat_interval") && bundle.containsKey("fire_date")) { SharedPreferences.Editor editor = sharedPreferences.edit(); @@ -227,7 +238,7 @@ public class SendNotificationTask extends AsyncTask { return null; } - public Bitmap getBitmapFromURL(String strURL) { + private Bitmap getBitmapFromURL(String strURL) { try { URL url = new URL(strURL); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); @@ -241,11 +252,10 @@ public class SendNotificationTask extends AsyncTask { } } - public String getMainActivityClassName() { + protected String getMainActivityClassName() { String packageName = mContext.getPackageName(); Intent launchIntent = mContext.getPackageManager().getLaunchIntentForPackage(packageName); - String className = launchIntent.getComponent().getClassName(); - return className; + return launchIntent != null ? launchIntent.getComponent().getClassName() : null; } }