Android Notification PendingIntent Extras null
in PendingIntent use this flag PendingIntent.FLAG_UPDATE_CURRENT it’s work for me PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
in PendingIntent use this flag PendingIntent.FLAG_UPDATE_CURRENT it’s work for me PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
adb shell dumpsys alarm > dump.txt dump.txt: Current Alarm Manager state: Realtime wakeup (now=1309361618777): RTC_WAKEUP #5: Alarm{4822f618 type 0 com.google.android.gsf} type=0 when=1309882326582 repeatInterval=522747000 count=0 operation=PendingIntent{47dd3740: PendingIntentRecord{4822aeb8 com.google.android.gsf broadcastIntent}} … RTC #5: Alarm{4810f9d8 type 1 com.tmobile.selfhelp} type=1 when=1309445979715 repeatInterval=86400000 count=1 operation=PendingIntent{4815a5c8: PendingIntentRecord{4810f960 com.tmobile.selfhelp startService}} RTC #4: Alarm{4810f668 type 1 com.tmobile.selfhelp} type=1 when=1309445959620 repeatInterval=86400000 count=1 operation=PendingIntent{480996e8: PendingIntentRecord{480214a0 … Read more
Maybe try this : NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID); OR, you can also do this to cancel all notifications in given context: notificationManager.cancelAll(); See this link to the documentation : NotificationManager
Don’t use Intent.FLAG_ACTIVITY_NEW_TASK for PendingIntent.getActivity, use FLAG_ONE_SHOT instead Copied from comments: Then set some dummy action on the Intent, otherwise extras are dropped. For example intent.setAction(Long.toString(System.currentTimeMillis()))
requestCode is used to retrieve the same pending intent instance later on (for cancelling, etc). Yes, my guess is the alarms will override each other. I would keep the request codes unique.
You can use this: <activity android:name=”.YourActivity” android:launchMode=”singleTask”/> which will work similar to “singleInstance” but it won’t have that weird animation.
Using PendingIntent.FLAG_CANCEL_CURRENT not a good solution because of inefficient use of memory. Instead use PendingIntent.FLAG_UPDATE_CURRENT. Use also Intent.FLAG_ACTIVITY_SINGLE_TOP (the activity will not be launched if it is already running at the top of the history stack). Intent resultIntent = new Intent(this, FragmentPagerSupportActivity.class). addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); resultIntent.putExtra(FragmentPagerSupportActivity.PAGE_NUMBER_KEY, pageNumber); PendingIntent resultPendingIntent = PendingIntent.getActivity( this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT ); Then: … Read more
You are sending the same request code for your pending intens. Change this: PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); To: PendingIntent contentIntent = PendingIntent.getActivity(context, UNIQUE_INT_PER_CALL, notificationIntent, 0); intents are not created if you send the same params. They are reused.
You can set your pending intent as val updatedPendingIntent = PendingIntent.getActivity( applicationContext, NOTIFICATION_REQUEST_CODE, updatedIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT // setting the mutability flag ) According to the docs here: https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies … Read more
if your android version is below Android – 6 then you need to add this line otherwise it will work above Android – 6. … Intent i = new Intent(this, Wakeup.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); …