Here you can find the source of createNotification(Intent resultIntent, Context current, final Class> destination)
public static void createNotification(Intent resultIntent, Context current, final Class<?> destination)
import java.util.ArrayList; import java.util.Collection; import android.app.Activity; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.TaskStackBuilder; import android.content.Context; import android.content.Intent; import android.graphics.Point; import android.hardware.Camera; import android.os.Build; import android.support.v4.app.NotificationCompat; import android.view.Display; import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout.LayoutParams; public class Main{ private static NotificationCompat.Builder mBuilder; private static int numMessages = 0; private static int notifyId = 1; public static void createNotification(Intent resultIntent, Context current, final Class<?> destination) { NotificationManager mNotificationManager = (NotificationManager) current .getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(current) .setContentTitle("Ho") .setContentText("You've received a new hoot") .setSmallIcon(R.drawable.ic_owl_white).setAutoCancel(true) .setNumber(numMessages++); if (numMessages > 1) { mBuilder.setContentText("You've received new hoots"); }//w w w . j a v a 2 s. c o m TaskStackBuilder stackBuilder = TaskStackBuilder.create(current); stackBuilder.addParentStack(destination); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mNotificationManager.notify(notifyId, mBuilder.build()); } }