Sync Activity with broadCast Receiver issue - android

I wanna sync my Activity with Google cloud Messaging.
When GCM message Receives Its own receiver get the message and create notification and then broadcast my custom message to activity receiver.
In other hand my Activity has own dynamically registered BroadcastReceiver that Receives my cusom messsages.
now this is a situation:
when app is open, without clicking on notification, my activity
receiver receives the message and shows.
but when activity is closed after clicking on notification noting
receives and app just opens.
I tried may ways like:
register a class BroadCast receiver On maifest. but I cannot sync it with my activity. cause I found that outer Receiver can sysnc with activity just with putextra and then my activity should close and then open again to can get extras!
try to broadcast my custom message again on creates notification, but it seems wont work cause I need to broad cast on NotificationClick not onCreate notification.
finnaly I tried to Register this internal reciver dynamically on another part of but It cannot reachable.
so if you get my problem what is the best way of solving?
this is my in activity receiver:
private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
Log.i("LOG", "unreciver");
String newMessage = intent.getExtras().getString(EXTRA_MESSAGE);
// Waking up mobile if it is sleeping
WakeLocker.acquire(getApplicationContext());
/**
* Take appropriate action on this message
* depending upon your app requirement
* For now i am just displaying it on the screen
* */
//Showing received message
//lblMessage.append(newMessage + "\n");
Log.i("LOG", "unreciver messsage:"+newMessage);
//Toast.makeText(getApplicationContext(), "New Message: " + newMessage, Toast.LENGTH_LONG).show();
loadReciverDialog(newMessage);
// Releasing wake lock
WakeLocker.release();
}
};
this is the part of service that receive message from GCM and Create notification:
#Override
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
String message = intent.getExtras().getString("price");
Log.i("LOG", "GCM service Message "+message);
displayMessage(context, message);
// notifies user
generateNotification(context, message);
}
private static void generateNotification(Context context, String message) {
Log.i("LOG", "genetaret notify");
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, MainActivity.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
//notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}
}
and this part display message:
static void displayMessage(Context context, String message) {
Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
intent.putExtra(EXTRA_MESSAGE, message);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
Log.i("LOG", "commonutils msg="+message);
context.sendBroadcast(intent);
}

I finally solve this problem in this way:
I kept the in-Activity Broadcast Receiver and made a function for checking if Extras exist my codes under OnReceive functions works.
after create notification put message to extra for Main Activity to get them
so my app get message in two way:
when app is opens message will gave with receiver
when app is closed message will gave to app by extra
but I wanna know if there is a better way to work with one Receiver.

Related

Android push notification: Get data, store and display on new activity on click of notification

I am developing an application which is having push notification functionality. I followed the following link as Android Push Notification
I tried and successfully send URL and open the web page on click of notification by doing the following change in code of generateNotification().
/**
* Issues a notification to inform the user that server has sent a message.
*/
private static void generateNotification(Context context, String message) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher, "Message received", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
//adding LED lights to notification
notification.defaults |= Notification.DEFAULT_LIGHTS;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(message));
//startActivity(browserIntent);
//PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
notification.setLatestEventInfo(context, "Message", "New message received", pendingIntent);
notificationManager.notify(0, notification);
I am able to send the data with the help of push notification from the server.
Now i want to perform following tasks:
Send JSON data via push notification.
Save the data into SQLite database.
Open new activity on click of push notification.
Display data coming from push notification of new activity.
If the application is closed so after click on notification the app get started.
So please guide me what steps should i follow to perform the above task.
I solved the issues as:
Send JSON data via push notification.
A. Able to send the data from SERVER with the help of PHP JSON service of size 4kb.
Save the data into SQLite database.
A. Saved the data in SQLite when data comes from push notification in onMessage()
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
String message = intent.getExtras().getString("price");
Log.d("OnMSG",message);
displayMessage(context, message);
DataBaseHelper dataBaseHelper = new DataBaseHelper(context);
dataBaseHelper.openDataBase();
dataBaseHelper.insertData(message);
dataBaseHelper.close();
// notifies user
generateNotification (context, message);
}
Open new activity on click of push notification.
A. I done this using pending intent in generate notification function called from onMessage().
private static void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.putExtra("ms", message);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}
Display data coming from push notification of new activity.
A. This achieves as when new activity invokes on click of notification (from above point 3 code) I get data from SQLite in main activity onCreate().
DataBaseHelper dataBaseHelper = new DataBaseHelper(this);
dataBaseHelper.openDataBase();
Cursor c = dataBaseHelper.getData();
String data = null;
if(c.getCount()>0){
if(c.moveToFirst()){
do{
data = c.getString(0);
} while(c.moveToNext());
}
} else {
data = "No Data";
}
If the application is closed so after click on notification the app get started.
A. This task is achieved from point no 3.
GCMIntentService.java
import com.google.android.gcm.GCMBaseIntentService;
import com.google.android.gcm.GCMRegistrar;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.util.Log;
/**
* IntentService responsible for handling GCM messages.
*/
public class GCMIntentService extends GCMBaseIntentService {
#SuppressWarnings("hiding")
private static final String TAG = "GCMIntentService";
public GCMIntentService() {
super(SENDER_ID);
}
#Override
protected void onRegistered(Context context, String registrationId) {
Log.i(TAG, "Device registered: regId = " + registrationId);
displayMessage(context,"onregisterd");
ServerUtilities.register(context, registrationId);
}
#Override
protected void onUnregistered(Context context, String registrationId) {
Log.i(TAG, "Device unregistered");
displayMessage(context, "GCM unregistered");
if (GCMRegistrar.isRegisteredOnServer(context)) {
ServerUtilities.unregister(context, registrationId);
} else {
// This callback results from the call to unregister made on
// ServerUtilities when the registration to the server failed.
Log.i(TAG, "Ignoring unregister callback");
}
}
#Override
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
String message =intent.getExtras().getString("message");
displayMessage(context, message);
// notifies user
generateNotification(context,message );
}
#Override
protected void onDeletedMessages(Context context, int total) {
Log.i(TAG, "Received deleted messages notification");
String message = ("total deleted"+ total);
displayMessage(context, message);
// notifies user
generateNotification(context, message);
}
#Override
public void onError(Context context, String errorId) {
Log.i(TAG, "Received error: " + errorId);
displayMessage(context, ("error:"+ errorId));
}
#Override
protected boolean onRecoverableError(Context context, String errorId) {
// log message
Log.i(TAG, "Received recoverable error: " + errorId);
displayMessage(context, ("Recover error:"+ errorId));
return super.onRecoverableError(context, errorId);
}
/**
* Issues a notification to inform the user that server has sent a message.
*/
private static void generateNotification(Context context, String message) {
int icon = R.drawable.icon;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, "Dear Customer , New Product has been Launched", when);
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notification.sound=soundUri;
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, lap_gcm.class);
notificationIntent.putExtra("message", message);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
}
}
Result Activity
lap_gcm.java
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class lap_gcm extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
String message=getIntent().getStringExtra("message");
//Here is Your message
}
}
This code base on the blog you mention i used in one of my application i develop. This will show notification on new notification receive and open a new activity when the user clicked the notification.
Always send don't send all data through push notification. u just send some small message like data then pull the data from the server, once the message received in your device, then store it in db.
Send JSON data via push notification
You can send the JSON as data in the notification message from your server side code. Once you get the notification then you would receive a JSON in the message where you can do whatever you want.
Save the data into SQLite database
This is simple as per your requirement, you can insert the data whatever received in the JSON. You can get the data from the JSON after parsing.
Open new activity on click of push notification.
You can do like below
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, YourActivity.class), 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_gcm)
.setContentTitle("GCM Notification")
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
Display data coming from push notification of new activity.
You can display the data whatever receive from push message but you have to parse the JSON.
If the application is closed so after click on notification the app get started.
My above code will work for you in this case also.
See here for JSON parsing : http://www.vogella.com/tutorials/AndroidJSON/article.html
All in all, you have to add the data in the JSON form in your server cod that you would get when you push the GCM from the server and later perform parse the JSON and do whatever you want.

Supply pending intent to class from notification in Android

I am creating an notification by sending GCM message to my app using this code
private static void generateNotification(Context context, int type, String title, String message) {
Intent notificationIntent;
int icon = R.drawable.ic_launcher;
java.util.Random v = new java.util.Random();
int id = v.nextInt(1000);
long when = System.currentTimeMillis();
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder notification = new NotificationCompat.Builder(context);
notificationIntent = new Intent(context, Home.class);
notificationIntent.putExtra(CommonUtilities.TITLE_ALERT, title);
notificationIntent.putExtra(CommonUtilities.EXTRA_MESSAGE, message);
notificationIntent.putExtra(CommonUtilities.TYPE, type);
notificationIntent.putExtra(CommonUtilities.ID, id);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, type, notificationIntent, PendingIntent.FLAG_ONE_SHOT);
Notification notification_view = notification.setContentTitle(title)
.setContentText(message).setContentIntent(intent)
.setSmallIcon(icon).setWhen(when)
.setVibrate(new long[] { 1000 }).build();
notification_view.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification_view.defaults |= Notification.DEFAULT_SOUND;
// notification_view.sound = Uri.parse("android.resource://" +
// context.getPackageName() + "your_sound_file_name.mp3");
// Vibrate if vibrate is enabled
notification_view.defaults |= Notification.DEFAULT_VIBRATE;
manager.notify(id, notification_view);
}
and receiving this pending intent using receiver
private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
if(!intent.hasExtra(CommonUtilities.TYPE)){
Log.v("msg", "intent vars not received");
return;
}
int type = intent.getExtras().getInt(CommonUtilities.TYPE);
String title = intent.getExtras().getString(CommonUtilities.TITLE_ALERT);
String newMessage = intent.getExtras().getString(CommonUtilities.EXTRA_MESSAGE);
String[] msgArr = newMessage.split(",");
Log.v("message", newMessage);
}
};
But my activity is not performing the action and showing me log. I have registered my receiver with a custom intent using
registerReceiver(mHandleMessageReceiver, new IntentFilter(CommonUtilities.DISPLAY_ACTION));
How can I find the error?
Edit
If application receives a notification while it is on foreground then notifications are received well but if the activity is not running or it is finished and I invoke it on notification click nothing happened
The code you have in generateNotification will only create a notification, not a broadcast.
Your Receiver won't ever receive anything because your'e never broadcasting. To utilize the receiver in the way you're using it you need to write code similar to this
public static final String DISPLAY_ACTION = "package.name.DISPLAY_MESSAGE";
public static final String EXTRA_MESSAGE = "message";
public static void displayMessage(Context context, String message) {
Intent intent = new Intent(DISPLAY_ACTION);
intent.putExtra(EXTRA_MESSAGE, message);
context.sendBroadcast(intent);
}
EDIT
I would add this code above to your CommonUtilities class, you also need to add this line to your generateNotification method
CommonUtilities.displayMessage(context, message);//this will then send your broadcast to the receiver.
EDIT - Show notification message when app is opened
I'm using similar functionality in my app. I saved the notification in a database as unread when it has been received by GCM and then alerted the user, as soon as the app is opened i checked for unread notifications and if found invoked the displayMessage method to show the user the missed notifications. After that I delete the notification from the db.
You wrote:
If application receives a notification while it is on foreground then
notifications are received well but if the activity is not running or
it is finished and I invoke it on notification click nothing happened
If you register your receiver from your activity by calling:
registerReceiver(mHandleMessageReceiver, new IntentFilter(CommonUtilities.DISPLAY_ACTION));
then you have registered the receiver using the context of the activity. That means that when the activity is finished, the registered receiver will be removed and destroyed (to prevent memory leaks).
If you want your receiver to be run even if your app is not running, then you need to register the receiver in the manifest, by adding an appropriate intent filter to your <receiver> definition:
<intent-filter>
<!-- use the correct name string for CommonUtilities.DISPLAY_ACTION) -->
<action android:name="blah.blah.blah.DISPLAY_ACTION"/>
</intent-filter>

C2DM- detecting how application is launched

so we have an iOS app and an Android app that each utilize their respective notification method frameworks... iOS has push and Android has C2DM (until we bring it up to GCM)... all is well on iOS, but i'm looking for a method of detecting if the app was launched by clicking a C2DM message (similar to the functionality of didFinishLaunchingWithOptions on iOS).
Currently, when the push message is received on Android, i do whatever processing that i need to do based on the data contained within the message's payload... so when the user launches the app their experience is determined by what was in that push message. This is the case regardless of whether they launch by pressing the icon on the home screen/history or push message. Ideally we'd like this to happen only if they select that message, and if they select the app from the home/history screen then it should launch normally.
You can save some data in the SharedPreferences on your onMessage listener in the GCMIntentService intent class. The GCM listener belongs to your package app after all.
What you save depends on your app and your message payload, but it may be whatever you want.
Then on your onCreate function of the Activity launched when clicking on the notification, you read the Shared Preferences to see whether you come from the GCM notification or not. Remember to clear the variable you save in the SharedPreferences so that next time that the user opens the app, it displays the content properly.
You have an example here. Unfortunately I cannot try it right now but it's useful to see the idea. It's quite similar to G2DM so you have to look for the equivalent in your case.
public class GCMIntentService extends GCMBaseIntentService {
/*... other functions of the class */
/**
* Method called on Receiving a new message
* */
#Override
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
String message = intent.getExtras().getString("your_message");
// notifies user
generateNotification(context, message);
}
/**
* Issues a notification to inform the user that server has sent a message.
*/
private static void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
// Save your data in the shared preferences
SharedPreferences prefs = getSharedPreferences("YourPrefs", MODE_PRIVATE);
SharedPreferences.Editor prefEditor = prefs.edit();
prefEditor.putBoolean("comesFromGCMNotification", true);
prefEditor.commit();
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, MainActivity.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}
}

how Data transfer can be done from service to activity?

I have multiple applications and a single service, i want to create a communication between the apps and the service. I am saving the value in the service which one of the application has sent. Now I am trying to read the same value by some another application from the service.
How this can be achieved? I don't want to call explicit intent from the service and neither implicit intents since implicit intents will give a selection option to choose the desired app, which i don't want. Please advice.
You can use Broadcast Receivers to do this job. You don't need a background service to do this. You can fire an intent and the same can be consumed by other applications which register for the specified intent filter.
using BroadcastReceiver,
public class AlarmReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
try {
// Bundle bundle = intent.getExtras();
// String message = bundle.getString("alarm_message");
// Toast.makeText(context,bundle.getString("eventName"), Toast.LENGTH_SHORT).show();
NotificationManager notificationManager =(NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
int icon = R.drawable.event;
CharSequence notiText = "Event Notification";
long time = System.currentTimeMillis();
#SuppressWarnings("deprecation")
Notification notification = new Notification(icon, notiText,time);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent notificationIntent = new Intent(context, Setting.class);
//put data in notificationIntent ....>>>>>
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context,intent.getStringExtra("eventName"),intent.getStringExtra("eventDescription"), contentIntent);
int SERVER_DATA_RECEIVED = 1;
Calendar cal=Calendar.getInstance();
Toast.makeText(context,"aavechhe "+intent.getBooleanExtra("Flag",false),Toast.LENGTH_SHORT).show();
if(intent.getIntExtra("month",0)==cal.get(Calendar.DAY_OF_MONTH))
{
Toast.makeText(context,"aavechhe "+cal.get(Calendar.DAY_OF_MONTH),Toast.LENGTH_SHORT).show();
notificationManager.notify(SERVER_DATA_RECEIVED, notification);
}
if(intent.getBooleanExtra("Flag",false))
notificationManager.notify(SERVER_DATA_RECEIVED, notification);
} catch (Exception e) {
Toast.makeText(context, "There was an error somewhere, but we still received an alarm", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}

Android Show Notification only when Message arrives

In Android, I have implemented Google Cloud Notification, which notifies when any message arrives, but it stays even when message is there, it shows icon in notification bar immediatly after installing application, is there any way to only show the notification when message arrives and hide it once the user clicks on it ??
Here is my code :
private static void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
//Intent notificationIntent = new Intent(context, MainActivity.class); //Open Activity
// set intent so it does not start a new activity
Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
notificationIntent.setData(Uri.parse("http://www.google.com")); //Open Link
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
//notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}
Without seeing where you are receiving messages and where you want to generate and cancel Notifications, it is very difficult to discern what you need to do to implement this, but I will give it a shot.
If you load the sample project for an Android Connected App Engine project (via GCM), you will notice that GCM data is received in a GCMBaseIntentService.
This class has a method you can override called onMessage() that will be called whenever you receive a GCM message. If you create the notification in this method, then your application will only generate a notification when a GCM message is received.
As for cancelling notifications- you can do so by calling the NotificationManager's cancel() method, passing the ID of the notification you want to cancel. Presumably you have some sort of Activity that displays messages to the user, and this would be a good place to cancel any outstanding Notifications relating to a specific message.

Categories

Resources