Skip to content Skip to sidebar Skip to footer

NotificationManager Crashes Only On Device

I have a problem that I can't explain. I have a main activity which contains a button. When this button is clicked, it launches a new activity which downloads an xml file from the

Solution 1:

In older android versions, your Notification has to have a content Intent, so that when the user clicks your Notification, something happens. This means you must:

Make an Intent object, pointing somewhere, such as your MainActivity. Make sure to add the Intent.FLAG_ACTIVITY_NEW_TASK flag.

Intent intent = new Intent (this, MainActivity.class);
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);

Convert it to a PendingIntent

PendingIntent pend = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

Finally, in the builder, call

notificationBuilder.setContentIntent (pend);

Post a Comment for "NotificationManager Crashes Only On Device"