Example usage for android.app TaskStackBuilder addParentStack

List of usage examples for android.app TaskStackBuilder addParentStack

Introduction

In this page you can find the example usage for android.app TaskStackBuilder addParentStack.

Prototype

public TaskStackBuilder addParentStack(ComponentName sourceActivityName) 

Source Link

Document

Add the activity parent chain as specified by the android.R.attr#parentActivityName parentActivityName attribute of the activity (or activity-alias) element in the application's manifest to the task stack builder.

Usage

From source file:com.i2r.xue.rate_this_place.visitedplace.GeofenceTransitionsIntentService.java

/**
 * Posts a notification in the notification bar when a transition is detected.
 * If the user clicks the notification, control goes to the MainActivity.
 *//*ww w  . ja  va 2  s  . c om*/
private void sendNotification(String notificationDetails) {
    // Create an explicit content Intent that starts the main Activity.
    Intent notificationIntent = new Intent(getApplicationContext(), VisitedPlacesActivity.class);

    // Construct a task stack.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

    // Add the main Activity to the task stack as the parent.
    stackBuilder.addParentStack(MainActivity.class);

    // Push the content Intent onto the stack.
    stackBuilder.addNextIntent(notificationIntent);

    // Get a PendingIntent containing the entire back stack.
    PendingIntent notificationPendingIntent = stackBuilder.getPendingIntent(0,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Get a notification builder that's compatible with platform versions >= 4
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);

    // Define the notification settings.
    builder.setSmallIcon(com.i2r.xue.rate_this_place.R.mipmap.ic_launcher)
            // In a real app, you may want to use a library like Volley
            // to decode the Bitmap.
            .setLargeIcon(BitmapFactory.decodeResource(getResources(),
                    com.i2r.xue.rate_this_place.R.mipmap.ic_launcher))
            .setColor(Color.RED).setContentTitle(notificationDetails)
            .setContentText(
                    getString(com.i2r.xue.rate_this_place.R.string.geofence_transition_notification_text))
            .setContentIntent(notificationPendingIntent);

    // Dismiss notification once the user touches it.
    builder.setAutoCancel(true);

    // Get an instance of the Notification manager
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    // Issue the notification
    mNotificationManager.notify(0, builder.build());
}

From source file:rtdc.android.presenter.InCallActivity.java

@Override
protected void onCreate(android.os.Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_in_call);

    // Force screen to stay on during the call

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    if (getResources().getBoolean(R.bool.isTablet))
        AndroidVoipController.get().setSpeaker(true);

    if (AndroidVoipController.get().isReceivingRemoteVideo() || AndroidVoipController.get().isVideoEnabled()) {
        displayVideo();/*www  .j a v  a 2s. c o  m*/
    } else {
        displayAudio();
    }

    // Build the intent that will be used by the notification

    Intent resultIntent = new Intent(this, InCallActivity.class);
    resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    // Build stack trace for the notification

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(AndroidBootstrapper.getAppContext());
    stackBuilder.addParentStack(InCallActivity.class);
    stackBuilder.addNextIntent(resultIntent);

    // Build notification

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_phone_white_24dp).setContentTitle(ResBundle.get().rtdcTitle())
            .setContentText(ResBundle.get()
                    .inCallWith(AndroidVoIPThread.getInstance().getCall().getFrom().getDisplayName()));
    PendingIntent inCallPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(inCallPendingIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(IN_CALL_NOTIFICATION_ID, mBuilder.build());

    AndroidVoIPThread.getInstance().addVoIPListener(this);
}

From source file:com.raspi.chatapp.util.Notification.java

public void createNotification(String buddyId, String name, String message, String type) {
    SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);

    if (defaultSharedPreferences
            .getBoolean(context.getResources().getString(R.string.pref_key_new_message_notifications), true)) {
        int index = buddyId.indexOf("@");
        if (index != -1)
            buddyId = buddyId.substring(0, index);
        if (name == null)
            name = buddyId;/*www.  j a v  a2 s  . c o m*/
        Log.d("DEBUG", "creating notification: " + buddyId + "|" + name + "|" + message);
        Intent resultIntent = new Intent(context, ChatActivity.class);
        resultIntent.setAction(NOTIFICATION_CLICK);
        String oldBuddyId = getOldBuddyId();
        Log.d("DEBUG",
                (oldBuddyId == null) ? ("oldBuddy is null (later " + buddyId) : ("oldBuddy: " + oldBuddyId));
        if (oldBuddyId == null || oldBuddyId.equals("")) {
            oldBuddyId = buddyId;
            setOldBuddyId(buddyId);
        }
        if (oldBuddyId.equals(buddyId)) {
            resultIntent.putExtra(Constants.BUDDY_ID, buddyId);
            resultIntent.putExtra(Constants.CHAT_NAME, name);
        }

        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
        stackBuilder.addParentStack(ChatActivity.class);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationManager nm = ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
        NotificationCompat.Style style;

        String[] previousNotifications = readJSONArray(CURRENT_NOTIFICATIONS);
        String title;
        String[] currentNotifications = Arrays.copyOf(previousNotifications, previousNotifications.length + 1);
        currentNotifications[currentNotifications.length - 1] = name + ": " + message;
        if (previousNotifications.length == 0) {
            style = new NotificationCompat.BigTextStyle();
            NotificationCompat.BigTextStyle bigTextStyle = ((NotificationCompat.BigTextStyle) style);
            title = context.getResources().getString(R.string.new_message) + " "
                    + context.getResources().getString(R.string.from) + " " + name;
            bigTextStyle.bigText(currentNotifications[0]);
            bigTextStyle.setBigContentTitle(title);
        } else {
            style = new NotificationCompat.InboxStyle();
            NotificationCompat.InboxStyle inboxStyle = (NotificationCompat.InboxStyle) style;
            title = (previousNotifications.length + 1) + " "
                    + context.getResources().getString(R.string.new_messages);
            for (String s : currentNotifications)
                if (s != null && !"".equals(s))
                    inboxStyle.addLine(s);
            inboxStyle.setSummaryText(
                    (currentNotifications.length > 2) ? ("+" + (currentNotifications.length - 2) + " more")
                            : null);
            inboxStyle.setBigContentTitle(title);
        }
        writeJSONArray(currentNotifications, CURRENT_NOTIFICATIONS);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setContentTitle(title)
                .setContentText(currentNotifications[currentNotifications.length - 1])
                .setSmallIcon(MessageHistory.TYPE_TEXT.equals(type) ? R.drawable.ic_forum_white_48dp
                        : R.drawable.ic_photo_camera_white_48dp)
                .setLargeIcon(getLargeIcon(Character.toUpperCase(name.toCharArray()[0]))).setStyle(style)
                .setAutoCancel(true).setPriority(5).setContentIntent(resultPendingIntent);

        String str = context.getResources().getString(R.string.pref_key_privacy);
        mBuilder.setVisibility(context.getResources().getString(R.string.pref_value1_privacy).equals(str)
                ? NotificationCompat.VISIBILITY_SECRET
                : context.getResources().getString(R.string.pref_value2_privacy).equals(str)
                        ? NotificationCompat.VISIBILITY_PRIVATE
                        : NotificationCompat.VISIBILITY_PUBLIC);

        str = context.getResources().getString(R.string.pref_key_vibrate);
        if (defaultSharedPreferences.getBoolean(str, true))
            mBuilder.setVibrate(new long[] { 800, 500, 800, 500 });

        str = context.getResources().getString(R.string.pref_key_led);
        if (defaultSharedPreferences.getBoolean(str, true))
            mBuilder.setLights(Color.BLUE, 500, 500);

        str = defaultSharedPreferences.getString(context.getResources().getString(R.string.pref_key_ringtone),
                "");
        mBuilder.setSound("".equals(str) ? RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
                : Uri.parse(str));

        nm.notify(NOTIFICATION_ID, mBuilder.build());
        str = context.getResources().getString(R.string.pref_key_banner);
        if (!defaultSharedPreferences.getBoolean(str, true)) {
            try {
                Thread.sleep(1500);
            } catch (InterruptedException e) {
            }
            reset();
        }
    }
}

From source file:org.secuso.privacyfriendlynetmonitor.ConnectionAnalysis.PassiveService.java

private void showAppNotification() {
    mBuilder.setSmallIcon(R.drawable.ic_notification);
    mBuilder.setLargeIcon(mIcon);/*from   www.  j av  a 2  s.com*/
    Intent resultIntent = new Intent(this, MainActivity.class);

    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(MainActivity.class);

    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    // mId allows you to update the notification later on.
    mNotificationManager.notify(Const.LOG_TAG, 1, mBuilder.build());
}

From source file:org.secuso.privacyfriendlynetmonitor.ConnectionAnalysis.PassiveService.java

private void showWarningNotification() {
    //Set corresponding icon
    //if(Evidence.getMaxSeverity() > 2){
    //    mBuilder.setSmallIcon(R.mipmap.icon_warn_red);
    //    mBuilder.setLargeIcon(mWarnRed);
    //} else {/*from  w w  w .  j a v  a  2 s  . co  m*/
    //    mBuilder.setSmallIcon(R.mipmap.icon_warn_orange);
    //    mBuilder.setLargeIcon(mWarnOrange);
    //}
    //mBuilder.setContentText(mNotificationCount + " new warnings encountered.");

    // Creates an explicit intent for an Activity in your app
    Intent resultIntent = new Intent(this, MainActivity.class);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(MainActivity.class);

    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    // mId allows you to update the notification later on.
    mNotificationManager.notify(Const.LOG_TAG, 1, mBuilder.build());
}

From source file:com.jay.pea.mhealthapp2.utilityClasses.AlarmReceiver.java

/**
 * OnRecieve method that recieves calls form the AlertManager class and then applies some logic to fire notifications to the user.
 *
 * @param context//from ww  w.  j a v  a 2s . c  o  m
 * @param intent
 */
@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "onRecieve");
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MedMinder");
    //Acquire the lock
    wl.acquire();

    dose = null;
    dose = (Dose) intent.getSerializableExtra(AlertManager.ALARMSTRING);
    Log.d(TAG,
            " This dose is " + dose.getMedication().getMedName() + "  " + dose.getDoseTime().toString(dtfTime));

    if (dose == null) {
        Log.d(TAG, "Alert object Extra is null");
    }

    //get the parent med
    Medication med = dose.getMedication();
    int alertCount = 0;
    for (DateTime doseDueDT : med.getDoseMap1().keySet()) {
        DateTime doseTakenDT = med.getDoseMap1().get(doseDueDT);
        if (doseDueDT.isBefore(new DateTime().now())
                && doseDueDT.isAfter(new DateTime().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0))
                && doseTakenDT.equals(new DateTime(0))) {
            alertCount++;
        }
    }

    if (alertCount == 0) {
        return;
    }

    SharedPreferences sharedPref = context.getSharedPreferences("AlertCounter", 0);
    int alertCountPref = sharedPref.getInt(med.getMedName(), 0);
    SharedPreferences.Editor editor = sharedPref.edit();

    DateTime now = new DateTime().now();
    int notifID = dose.getMedication().getDbID();
    Random rand = new Random();
    //int notifID = rand.nextInt();
    Log.d(TAG, dose.getMedication().getDbID() + "   " + dose.getDoseTime().getMillisOfDay());

    if (dose.getTakenTime().toString(dtfDate).equals(new DateTime(0).toString(dtfDate))) {
        //            if ((dose.getDoseTime().getMillis() + alertMissedWindowArray[dose.getMedication().getFreq() - 1] * 2) > new DateTime().getMillis());
        String alertString = "You have " + alertCount + " missed doses for " + med.getMedName();
        if (alertCount == 1) {
            alertString = "You have a missed dose for " + med.getMedName();
        }

        //check if the dose is due +/- 15mins and advise that a dose is due.
        long diffMillis = dose.getDoseTime().getMillis() - new DateTime().now().getMillis();
        Log.d(TAG, diffMillis + "   dose time = " + dose.getDoseTime().getMillis() + " now= "
                + new DateTime().now().getMillis());
        boolean doseDue = Math.abs(diffMillis) < 1800000;
        if (doseDue) {
            alertString = dose.getMedication().getDose() + " of " + dose.getMedication().getMedName()
                    + " is due now.";
        }

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.mipmap.medminder_icon).setContentTitle("MedMinder").setContentText(alertString);

        Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        mBuilder.setSound(alarmSound);
        // Creates an explicit intent for an Activity in your app
        Intent resultIntent = new Intent(context, MainActivity.class);

        // The stack builder object will contain an artificial back stack for the started Activity.
        // This ensures that navigating backward from the Activity leads out of your application to the Home screen.
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
        // Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addParentStack(MainActivity.class);
        // Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);

        // mId allows you to update the notification later on.
        mNotificationManager.notify(notifID, mBuilder.build());
        Log.d(TAG, " Notification sent " + notifID);
        //
        //
        //            editor.putInt(med.getMedName(), alertCount);
        //            editor.commit();

        //Release the lock
        wl.release();
    }
}

From source file:com.kdb.ledcontrol.LEDManager.java

public void setOnBoot() {
    String cmd = prefs.getString("last_cmd", null);
    int brightness = prefs.getInt("last_brightness", -1);
    if (brightness != -1 && devicePathToBrightness != null) {
        brightness /= 25;/* w  w w  .  j  a  v  a  2s . c  o m*/
        ApplyBrightness(brightness);
    }
    if (cmd != null && devicePathToLED != null) {
        try {
            deviceInput.writeBytes("echo " + cmd + " > " + devicePathToLED + "\n");
            deviceInput.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if (checkState() != -1 && prefs.getBoolean("show_notif", true)) {
        Log.i(TAG, "LED trigger applied on boot");
        Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.ic_stat_notification).setLargeIcon(largeIcon)
                .setContentTitle(context.getString(R.string.app_name_full))
                .setContentText(context.getString(R.string.notification_content));
        Intent resultIntent = new Intent(context, MainActivity.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
        stackBuilder.addParentStack(MainActivity.class);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        builder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(0, builder.build());
    }
}

From source file:org.fairphone.peaceofmind.PeaceOfMindBroadCastReceiver.java

/**
 * Sets the Peace of mind icon on the notification bar
 * @param putIcon if true the icon is put otherwise it is removed
 * @param wasInterrupted when true, an extra notification is sent to inform the user that Peace of mind was ended
 *///w  w  w. j  a va2  s  .c  om
private void setPeaceOfMindIconInNotificationBar(boolean putIcon, boolean wasInterrupted) {

    NotificationManager manager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);

    if (putIcon) {

        //just in case the user didn't clear it
        manager.cancel(PEACE_OF_MIND_INTERRUPTED_NOTIFICATION);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
                .setSmallIcon(R.drawable.peace_system_bar_icon)
                .setContentTitle(mContext.getResources().getString(R.string.app_name))
                .setContentText(mContext.getResources().getString(R.string.peace_on_notification));

        Intent resultIntent = new Intent(mContext, PeaceOfMindActivity.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
        // Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addParentStack(PeaceOfMindActivity.class);
        // Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

        builder.setContentIntent(resultPendingIntent);

        Notification notificationWhileRunnig = builder.build();
        notificationWhileRunnig.flags |= Notification.FLAG_NO_CLEAR;
        // Add notification   
        manager.notify(PEACE_OF_MIND_ON_NOTIFICATION, notificationWhileRunnig);

    } else {
        manager.cancel(PEACE_OF_MIND_ON_NOTIFICATION);

        //send a notification saying that the peace was ended 
        if (wasInterrupted) {
            NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
                    .setSmallIcon(R.drawable.peace_system_bar_icon).setAutoCancel(true)
                    .setContentTitle(mContext.getResources().getString(R.string.app_name))
                    .setContentText(mContext.getResources().getString(R.string.peace_off_notification))
                    .setTicker(mContext.getResources().getString(R.string.peace_off_notification));

            manager.notify(PEACE_OF_MIND_INTERRUPTED_NOTIFICATION, builder.build());
        }
    }
}

From source file:org.protocoderrunner.apprunner.api.PApp.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@ProtocoderScript/* w w  w. j a v  a2  s  . c o m*/
@APIMethod(description = "", example = "")
@APIParam(params = { "id", "title", "description" })
public void setNotification(int id, String title, String description) {
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(a.get())
            .setSmallIcon(R.drawable.app_icon).setContentTitle(title).setContentText(description);
    // Creates an explicit intent for an Activity in your app
    Intent resultIntent = new Intent(a.get(), AppRunnerActivity.class);

    // The stack builder object will contain an artificial back stack for
    // the started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(a.get());
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(AppRunnerActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager = (NotificationManager) a.get()
            .getSystemService(a.get().NOTIFICATION_SERVICE);
    // mId allows you to update the notification later on.
    mNotificationManager.notify(id, mBuilder.build());

}

From source file:org.travey.travey.LocationIntentService.java

public void createNotification() {
    //create a notification that prompts the user to fill out a form about the trip
    Log.i("**************", "Notifying");
    if (travey.LOG_TO_DATABASE) {
        logToDatabase("notifying");
    }/*from   ww  w  .ja v  a2s .  com*/
    Resources res = getResources();

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
    mBuilder.setContentTitle(res.getString(R.string.trip_notification_title));
    mBuilder.setContentText(res.getString(R.string.trip_notification_body));
    mBuilder.setTicker(res.getString(R.string.trip_notification_ticker));
    mBuilder.setSmallIcon(R.drawable.ic_traveyd);
    mBuilder.setAutoCancel(true);

    //make intent for launching survey if they click on the notification
    Intent mainIntent = new Intent(this, MainActivity.class);
    //Pass along trip data (maybe can do this better with Parcelable)
    mainIntent.putExtra("tab", "surveys");
    mainIntent.putExtra("fromNotify", "true");
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(mainIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_ONE_SHOT);
    mBuilder.setContentIntent(resultPendingIntent);

    //TESTING TO SEE IF FOLLOWING CAN BE REMOVED ALONG WITH RECEIVER CLASS
    //make intent for cleaning up if they dismiss the notification
    Intent dismissIntent = new Intent(this, NotificationDismissedReceiver.class);
    dismissIntent.putExtra("com.my.app.notificationId", travey.NOTIFY_ID);
    PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(),
            travey.NOTIFY_ID, dismissIntent, 0);
    mBuilder.setDeleteIntent(dismissPendingIntent);

    //launch the notification
    NotificationManager myNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    myNotificationManager.notify(0, mBuilder.build());

    //handle preferences
    Log.i("**************", "Setting notification pref to true");
    //reset the trip
    myPrefs = this.getSharedPreferences("myPrefs", MODE_PRIVATE);
    myPrefsEditor = myPrefs.edit();
    currentTrip = null;
    myPrefsEditor.putBoolean("isNotified", true);
    myPrefsEditor.commit();
}