Activity never starts when you click on a notification for Android version 4.0

Here is the notification implementation code:

Notification notification = new Notification(); RemoteViews expandedView = new RemoteViews(mContext.getPackageName(), R.layout.status_bar_ongoing_event_progress_bar); // ignore the setup code for expanedView notification.contentView = expandedView; Intent intent = new Intent(mContext, MyActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.contentIntent = contentIntent; mNotificationMgr.notify(notification_id, notification); 

This code works fine on Android 2.2 device, however it does not work on Android 4.0 device. When the user clicks the notification, MyActivity does not start and nothing happens.

I do not know the reason.

+4
source share
1 answer

I don’t know exactly what the problem is of your code, but if you use the code from android Dev

Lossless on ICS and pre ICS

Check this code recently

+1
source

Source: https://habr.com/ru/post/1432622/


All Articles