Reputation:
I am trying to create a custom notification with the help of remote view with a button on it. I want to write onclick listener for this button but the problem is that the notification container is catching the touch event and button is not being clicked. My question is Is there any way to disable this notification and let the button to be clicked. My code is something like below:
Notification notification = new Notification(R.drawable.applogo,
"Apps activated", System.currentTimeMillis());
Intent notificationIntent = new Intent(getBaseContext(), AppsActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(),
0, notificationIntent , 0);
notification.contentIntent = pendingIntent;
//Remoteview and intent for my button
RemoteViews remoteView = new RemoteViews(getBaseContext().getPackageName(),
R.layout.customnotification);
Intent mIntent = getPackageManager().getLaunchIntentForPackage(c.getString(1));//starting some application through package
PendingIntent pintent = PendingIntent.getActivity(this, 0,
mIntent, 0);
remoteView.setOnClickPendingIntent(R.id.button1,
pintent);
notification.contentView = remoteView;
notificationManager.notify(CUSTOM_NOTIFICATION_ID, notification);
I am working on api 7. Thanks
Upvotes: 2
Views: 1282
Reputation: 5057
Unfortunately, clickable buttons within notification layout available only with Custom notifications for API >= 11.
Also, for API >= 16 you can use Notification Actions to provide buttons within notification.
Upvotes: 2