Example usage for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS

List of usage examples for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.

Prototype

int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS

To view the source code for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.

Click Source Link

Document

If set, the new activity is not kept in the list of recently launched activities.

Usage

From source file:cc.psdev.heywifi.MainService.java

private void showTurnedoffNoti(int type) {
    if (type == 1 && alreadyNoticed == 0) {
        NotificationCompat.Builder noti = new NotificationCompat.Builder(this);
        noti.setSmallIcon(R.drawable.ic_notification);
        noti.setContentTitle(getResources().getString(R.string.stopnoti_title));
        noti.setTicker(getResources().getString(R.string.stopnoti_ticker));
        noti.setContentText(getResources().getString(R.string.stopnoti_text));
        noti.setOngoing(true);//from   ww  w .  j av a 2s.com

        Intent notiIntent = new Intent(this, SelectRunServiceActivity.class);
        notiIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

        // TODO: pendingIntent
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 1320001, notiIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        noti.setContentIntent(pendingIntent);

        nm.notify(1111, noti.build());
        alreadyNoticed = 1;
    } else if (type == 0) {
        nm.cancel(1111);
        alreadyNoticed = 0;
    }
}

From source file:com.android.screenspeak.ScreenSpeakUpdateHelper.java

private void notifyUserOfBuiltInGestureChanges() {
    // Build the intent for when the notification is clicked.
    final Intent notificationIntent = new Intent(mService, NotificationActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    notificationIntent.putExtra(NotificationActivity.EXTRA_INT_DIALOG_TITLE,
            R.string.notification_title_screenspeak_gestures_changed);
    notificationIntent.putExtra(NotificationActivity.EXTRA_INT_DIALOG_MESSAGE,
            R.string.screenspeak_built_in_gesture_change_details);
    notificationIntent.putExtra(NotificationActivity.EXTRA_INT_NOTIFICATION_ID,
            BUILT_IN_GESTURE_CHANGE_NOTIFICATION_ID);

    NotificationPosterRunnable runnable = new NotificationPosterRunnable(
            buildGestureChangeNotification(notificationIntent), BUILT_IN_GESTURE_CHANGE_NOTIFICATION_ID);
    mHandler.postDelayed(runnable, NOTIFICATION_DELAY);
}

From source file:org.getlantern.firetweet.service.BackgroundOperationService.java

private Notification buildNotification(final String title, final String message, final int icon,
        final Intent content_intent, final Intent deleteIntent) {
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setTicker(message);//from  w w w . j  a  v a 2 s . co m
    builder.setContentTitle(title);
    builder.setContentText(message);
    builder.setAutoCancel(true);
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(icon);
    if (deleteIntent != null) {
        builder.setDeleteIntent(
                PendingIntent.getBroadcast(this, 0, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    if (content_intent != null) {
        content_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        builder.setContentIntent(
                PendingIntent.getActivity(this, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    // final Uri defRingtone =
    // RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    // final String path =
    // mPreferences.getString(PREFERENCE_KEY_NOTIFICATION_RINGTONE, "");
    // builder.setSound(isEmpty(path) ? defRingtone : Uri.parse(path),
    // Notification.STREAM_DEFAULT);
    // builder.setLights(HOLO_BLUE_LIGHT, 1000, 2000);
    // builder.setDefaults(Notification.DEFAULT_VIBRATE);
    return builder.build();
}

From source file:com.sean.nanastudio.taoyuanstreetparking.MainActivity.java

public static void startInstalledAppDetailsActivity(final Activity context) {
    if (context == null) {
        return;/*  ww  w. j av a2s  .  c o  m*/
    }
    final Intent i = new Intent();
    i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    i.addCategory(Intent.CATEGORY_DEFAULT);
    i.setData(Uri.parse("package:" + context.getPackageName()));
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    context.startActivity(i);
}

From source file:com.android.talkback.TalkBackUpdateHelper.java

private void notifyUserOfBuiltInGestureChanges() {
    // Build the intent for when the notification is clicked.
    final Intent notificationIntent = new Intent(mService, NotificationActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    notificationIntent.putExtra(NotificationActivity.EXTRA_INT_DIALOG_TITLE,
            R.string.notification_title_talkback_gestures_changed);
    notificationIntent.putExtra(NotificationActivity.EXTRA_INT_DIALOG_MESSAGE,
            R.string.talkback_built_in_gesture_change_details);
    notificationIntent.putExtra(NotificationActivity.EXTRA_INT_NOTIFICATION_ID,
            BUILT_IN_GESTURE_CHANGE_NOTIFICATION_ID);

    NotificationPosterRunnable runnable = new NotificationPosterRunnable(
            buildGestureChangeNotification(notificationIntent), BUILT_IN_GESTURE_CHANGE_NOTIFICATION_ID);
    mHandler.postDelayed(runnable, NOTIFICATION_DELAY);
}

From source file:com.hacktx.android.activities.MainActivity.java

private void setupAppShortcuts() {
    // Setup app shortcuts
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1
            && mConfigManager.getValue(ConfigParam.CHECK_IN)) {
        ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

        Intent checkInIntent = new Intent(Intent.ACTION_VIEW);
        checkInIntent.setPackage("com.hacktx.android");
        checkInIntent.setClass(this, CheckInActivity.class);
        checkInIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_HISTORY
                | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
        checkInIntent.putExtra("fromShortcut", true);

        ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "check-in")
                .setShortLabel(getString(R.string.app_shortcut_check_in))
                .setLongLabel(getString(R.string.app_shortcut_check_in))
                .setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher)).setIntent(checkInIntent).build();

        shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut));
    }/*from   w  w  w . jav a 2 s .com*/
}

From source file:com.golden.android.eyecare.ForegroundService.java

void launchCount() {

    Intent dialogIntent = new Intent(getApplicationContext(), Count.class);
    dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    dialogIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    startActivity(dialogIntent);//w w  w.j a  va 2s. c om
    stopForeground(true);
    stopSelf();

}

From source file:com.android.talkback.TalkBackUpdateHelper.java

private void notifyUserOfBuiltInGestureChanges45() {
    // Expected behavior:
    // 1. If user has changed neither up nor down: clear both prefs (reset to default).
    //    User will see a change only in this case, so present a notification.
    // 2. If user has changed either setting, make sure that the gesture behavior stays the
    //    same (even if the user has changed one gesture and not the other).

    // Set the up and down gestures to the old defaults if the user hasn't modified them yet.
    final Editor editor = mSharedPreferences.edit();
    deprecateStringPreference(editor, R.string.pref_shortcut_up_key, R.string.pref_deprecated_shortcut_up);
    deprecateStringPreference(editor, R.string.pref_shortcut_down_key, R.string.pref_deprecated_shortcut_down);
    editor.apply();//from   w  w w  . j  a v  a2  s.  c  o  m

    // Are the preferences both equal to the old default?
    String upPrefKey = mService.getString(R.string.pref_shortcut_up_key);
    String downPrefKey = mService.getString(R.string.pref_shortcut_down_key);
    String upPrefDeprecated = mService.getString(R.string.pref_deprecated_shortcut_up);
    String downPrefDeprecated = mService.getString(R.string.pref_deprecated_shortcut_down);

    // Only reset prefs if the user has changed at least one of them to a non-default value.
    boolean prefsMatchDeprecated = upPrefDeprecated.equals(mSharedPreferences.getString(upPrefKey, null))
            && downPrefDeprecated.equals(mSharedPreferences.getString(downPrefKey, null));
    if (prefsMatchDeprecated) {
        editor.remove(upPrefKey);
        editor.remove(downPrefKey);
        editor.apply();

        // Build the intent for when the notification is clicked.
        final Intent notificationIntent = new Intent(mService, NotificationActivity.class);
        notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        notificationIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        notificationIntent.putExtra(NotificationActivity.EXTRA_INT_DIALOG_TITLE,
                R.string.notification_title_talkback_gestures_changed);
        notificationIntent.putExtra(NotificationActivity.EXTRA_INT_DIALOG_MESSAGE,
                R.string.talkback_built_in_gesture_change_details_45);
        notificationIntent.putExtra(NotificationActivity.EXTRA_INT_NOTIFICATION_ID,
                BUILT_IN_GESTURE_CHANGE_NOTIFICATION_ID);

        NotificationPosterRunnable runnable = new NotificationPosterRunnable(
                buildGestureChangeNotification(notificationIntent), BUILT_IN_GESTURE_CHANGE_NOTIFICATION_ID);
        mHandler.postDelayed(runnable, NOTIFICATION_DELAY);
    }
}

From source file:de.persoapp.android.core.adapter.MainViewFragment.java

protected void excludeFromRecentAppList(Activity activity) {
    // a dirty hack to exclude this activity from the recent app list after the process finished
    // since it runs in singleInstance mode onNewIntent will be called
    final Intent intent = new Intent(activity, activity.getClass());
    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    startActivity(intent);/*from   www.j  av  a2 s.c  om*/
}

From source file:com.golden.android.eyecare.ForegroundService.java

void notify(Intent intent) {

    if (intent.getAction().equals(Constants.ACTION.STARTFOREGROUND_ACTION)) {
        Log.i(LOG_TAG, "Received Start Foreground Intent ");

        ////from  ww  w .  java2  s  .  c  o  m
        //            Intent notificationIntent = new Intent(this, MainActivity.class);
        //            notificationIntent.setAction(Constants.ACTION.MAIN_ACTION);
        //            notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
        //                    | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        //            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
        //                    notificationIntent, 0);

        Intent notificationIntent = new Intent(this, ForegroundService.class);
        notificationIntent.setAction(Constants.ACTION.STOPFOREGROUND_ACTION);
        PendingIntent pendingIntent = PendingIntent.getService(this, 0, notificationIntent,
                PendingIntent.FLAG_CANCEL_CURRENT);

        Intent previousIntent = new Intent(this, ForegroundService.class);
        previousIntent.setAction(Constants.ACTION.PREV_ACTION);
        PendingIntent ppreviousIntent = PendingIntent.getService(this, 0, previousIntent, 0);

        Intent playIntent = new Intent(this, ForegroundService.class);
        playIntent.setAction(Constants.ACTION.STOPFOREGROUND_ACTION);
        PendingIntent pplayIntent = PendingIntent.getService(this, 0, playIntent, 0);

        Intent nextIntent = new Intent(this, ForegroundService.class);
        nextIntent.setAction(Constants.ACTION.NEXT_ACTION);
        PendingIntent pnextIntent = PendingIntent.getService(this, 0, nextIntent, 0);

        Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_eye);
        Intent dialogIntent = new Intent(getApplicationContext(), Count.class);
        dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        dialogIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        //  startActivity(dialogIntent);
        PendingIntent pplayIntent1 = PendingIntent.getService(this, 0, dialogIntent, 0);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
        builder.setContentTitle("Truiton Music Player");
        builder.setTicker("Truiton Music Player");
        builder.setContentText("My Music");
        builder.setSmallIcon(R.drawable.ic_eye);
        builder.setContentIntent(pendingIntent);
        builder.setOngoing(false);
        Notification notification = builder.build();
        startForeground(Constants.NOTIFICATION_ID.FOREGROUND_SERVICE, notification);
    } else if (intent.getAction().equals(Constants.ACTION.STOPFOREGROUND_ACTION)) {
        Log.i(LOG_TAG, "Received Stop Foreground Intent");
        launchCount();
    }
}