Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h3>You can send a notification and specify what Activity should be run when user initiates it:</h3> <pre><code> 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 </code></pre> <h3>You can start another Activity:</h3> <pre><code>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; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload