Sunday 2 March 2014

Android Notification example



final NotificationManager mgr =(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Notification note = new Notification(R.drawable.phone,"Vacant Class Notification..!", System.currentTimeMillis());
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

// This pending intent will open after notification click
PendingIntent i = PendingIntent.getActivity(this, 0,new Intent(this, NotificationReceiver.class), 0);
note.setLatestEventInfo(getApplicationContext(), "Vacant Class Notification..!",message, i);
note.sound = soundUri;

mgr.notify(0, note);