title: Android how to show notification on screen
body: <p>I've been working on push notifications and I am able to implement it and display it on status bar, the problem I am facing is that I want to display it even if the phone is lock, Under the lock screen where it says ("drag to unlock"), I have seen notifications like that but cant find any example to that.</p>
  
  <p><strong>Example:</strong>
  Just like when you received a missed call , it will show it under the lock button on your screen.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>String ns = Context.NOTIFICATION_SERVICE;
  NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
  int icon = R.drawable.icon_launcher;
  CharSequence tickerText = "MyApplication";
  long when = System.currentTimeMillis();
  Notification notification = new Notification(icon, tickerText, when);
  notification.defaults |= Notification.DEFAULT_SOUND|Notification.DEFAULT_VIBRATE|Notification.DEFAULT_LIGHTS;;
  CharSequence contentTitle = this.title;
  CharSequence contentText = this.message;
  Intent notificationIntent = new Intent(this, MainActivity.class);
  PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
  notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
  mNotificationManager.notify(NOTICE_ID, notification);
  </code></pre>