Вы можете отправить уведомление и указать, какое действие следует запустить, когда пользователь инициирует его:
private void sendNotification(Bundle bundle){
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.icon;
CharSequence tickerText = "bla bla";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(this, ACTIVITY_YOU_WANT_TO_START.class);
if(bundle!=null)
notificationIntent.putExtras(bundle); //you may put bundle or not
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
int any_ID_you_want = 1;
//if you send another notification with same ID, this will be replaced by the other one
mNotificationManager.notify(HELLO_ID, notification);
}
//To play a sound add this:
notification.sound = Uri.parse("file:///sdcard/notification/ringer.mp3"); //for example
Вы можете запустить другое действие:
private boolean startActivity(Bundle bundle){
Intent myIntent = new Intent(mContext, ACTIVITY_YOU_WANT_TO_START.class);
if(bundle!=null)
myIntent.putExtras(bundle);//optional
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(myIntent);
return true;
}