PendingIntents in Notifications
Posted
by Mariano Kamp
on Stack Overflow
See other posts from Stack Overflow
or by Mariano Kamp
Published on 2010-05-13T12:41:41Z
Indexed on
2010/05/13
12:44 UTC
Read the original article
Hit count: 308
android
I would like to show a notification that displays the progress of an ongoing operation. That works well for me. But at the same time the remote view should contain cancel button to stop the ongoing operation. The usual content intent should still do something else, i.e. not cancel the ongoing operation. It seems though that I can only have one intent.
I have to specify a contentIntent that is launched when clicking on the notification: If I don't specify that I get something along those lines:
E/ActivityManager( 62): Activity Manager Crash
E/ActivityManager( 62): java.lang.IllegalArgumentException: contentIntent required ...
For the "cancel" button I set another intent:
Intent cancelSyncIntent = new Intent("com.xyz.CANCEL_SYNC");
contentView.setOnClickPendingIntent(R.id.cancel_sync,
PendingIntent.getBroadcast(context, 0,
cancelSyncIntent, 0));
But this never works. I always get the content intent when the button is clicked. It looks like I cannot use buttons in remote views of notifications?!
I could probably display a text: "<< Press to cancel operation >>", but that seems rather heavy handed.
© Stack Overflow or respective owner