Get IntentSender object for createChooser method in Android

The chooser target intent is not a PendingIntent. For instance, in the following snippet, I am declaring intent for ACTION_SEND, with type text/plain, and this is the my target intent for the Intent.createChooser. Then I am creating another Intent, receiver, and a handler, the PendingIntent, which will invoke onReceive of my BroadcastReceiver after the user … Read more

Multiple notifications to the same activity

If the PendingIntent has the same operation, action, data, categories, components, and flags it will be replaced. Depending on the situation i usually solve this by providing a unique request code either as static values (0,1,2) or the row id of the data I’m receiving from the DB. PendingIntent.getActivity(context, MY_UNIQUE_VALUE , notificationIntent, PendingIntent.FLAG_ONE_SHOT); Then I … Read more

Delete alarm from AlarmManager using cancel() – Android

Try this flag: PendingIntent.FLAG_UPDATE_CURRENT Instead of: PendingIntent.FLAG_CANCEL_CURRENT So the PendingIntent will look like this: PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, alert.idAlert, intent, PendingIntent.FLAG_UPDATE_CURRENT) (Make sure that you use same alert object and mContext!) A side note: If you want one global AlarmManager, put the AlarmManager in a static variable (and initialize it only if it’s null).

Pending intent in notification not working

try this: private void setNotification(String notificationMessage) { //**add this line** int requestID = (int) System.currentTimeMillis(); Uri alarmSound = getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mNotificationManager = getApplication().getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(getApplicationContext(), NotificationActivity2.class); //**add this line** notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); //**edit this line to put requestID as requestCode** PendingIntent contentIntent = PendingIntent.getActivity(this, requestID,notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(R.drawable.logo) .setContentTitle(“My … Read more

Android cannot pass intent extras though AlarmManager

UPDATE: Please see Vincent Hiribarren’s solution Old Answer… Haresh’s code is not the complete answer… I used a Bundle and I tried without Bundle but I got null’s either way when I attempting to obtain the strings from the extra’s !! The exact problem, in your code, is with the PendingIntent ! This is wrong … Read more

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified

If using java or react-native then paste this inside app/build.gradle dependencies { // … implementation ‘androidx.work:work-runtime:2.7.1’ } If using Kotlin then use this dependencies { // … implementation ‘androidx.work:work-runtime-ktx:2.7.0’ } and if anybody still facing the crash issue for android 12 then make sure you add following in AndroidMenifest.xml <activity … android:exported=”true” // in most … Read more

How to open fragment page, when pressed a notification in android

If you are using Navigation Component you can open a specific destination using NavDeepLinkBuilder: val pendingIntent = NavDeepLinkBuilder(context) .setComponentName(MainActivity::class.java) .setGraph(R.navigation.nav_graph) .setDestination(R.id.destination) .setArguments(bundle) .createPendingIntent() … notificationBuilder.setContentIntent(pendingIntent) … Please note that it’s important to use setComponentName only if your destination isn’t in the launcher activity.

tech