Android Intent Create createNotification(Intent resultIntent, Context current, final Class destination)

Here you can find the source of createNotification(Intent resultIntent, Context current, final Class destination)

Description

create Notification

Declaration

public static void createNotification(Intent resultIntent,
            Context current, final Class<?> destination) 

Method Source Code

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());
    }
}

Related

  1. callHTTPDownload(Context context, String chooserTilte, String url)
  2. callPhone(Context context, String number)
  3. constructGoogleCalendarIntentVariant1()
  4. constructGoogleCalendarIntentVariant2()
  5. getExtraObject(Activity context, String key)
  6. gotoHome(Context context)
  7. locate(Context context, String chooserTilte, String lat, String lng, String addr)
  8. putParamters(Intent intent, Object[] parameters)