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:com.crea_si.eviacam.service.SplashActivity.java

private void checkRequisites() {
    if (!Eula.wasAccepted(this)) {
        Eula.acceptEula(this, this);
        return;//from   w  w w  . jav a2  s . c  om
    }

    if (checkPermissions()) {
        // If all permissions granted resume service initialization
        // TODO: remove such ugly static method call
        MainEngine.splashReady(isA11YService());

        /**
         * Restart this activity so that it does not show up in recents
         * nor when pressing back button
         */
        Intent dialogIntent = new Intent(this, SplashActivity.class);
        dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
                | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_HISTORY);
        dialogIntent.putExtra(IS_A11Y_SERVICE_PARAM, isA11YService());
        dialogIntent.putExtra(IS_SECOND_RUN_PARAM, true);
        startActivity(dialogIntent);
    }
}

From source file:ru.dublgis.androidhelpers.DesktopUtils.java

public static void showApplicationSettings(final Context ctx) {
    try {/*  w w w. j  a  v  a 2 s  .c o  m*/
        final Intent intent = new Intent();

        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.setData(Uri.fromParts("package", ctx.getPackageName(), null));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

        ctx.startActivity(intent);
    } catch (final Throwable throwable) {
        Log.e(TAG, "showApplicationSettings throwable: " + throwable);
    }
}

From source file:org.androidpn.client.SerivceManager.Notifier.java

public void notify(String notificationId, String apiKey, String title, String message, String uri) {
    Log.d(LOGTAG, "notify()...");

    Log.d(LOGTAG, "notificationId=" + notificationId);
    Log.d(LOGTAG, "notificationApiKey=" + apiKey);
    Log.d(LOGTAG, "notificationTitle=" + title);
    Log.d(LOGTAG, "notificationMessage=" + message);
    Log.d(LOGTAG, "notificationUri=" + uri);

    if (isNotificationEnabled()) {
        // Show the toast
        if (isNotificationToastEnabled()) {
            Toast.makeText(context, message, Toast.LENGTH_LONG).show();
        }/*from w w  w . j a  v a  2 s  .c o  m*/

        // PNNotification
        int ntfyDefaults = Notification.DEFAULT_LIGHTS;
        if (isNotificationSoundEnabled()) {
            ntfyDefaults |= Notification.DEFAULT_SOUND;
        }
        if (isNotificationVibrateEnabled()) {
            ntfyDefaults |= Notification.DEFAULT_VIBRATE;
        }

        Intent intent;
        //launch mainactivity
        if (uri == null || uri.length() <= 0) {
            intent = new Intent(context, MainActivity.class);
        } else {
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(uri));
        }
        /*
        intent.putExtra(Constants.NOTIFICATION_ID, notificationId);
        intent.putExtra(Constants.NOTIFICATION_API_KEY, apiKey);
        intent.putExtra(Constants.NOTIFICATION_TITLE, title);
        intent.putExtra(Constants.NOTIFICATION_MESSAGE, message);
        intent.putExtra(Constants.NOTIFICATION_URI, uri);*/
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        Notification.Builder notification = new Notification.Builder(context).setContentTitle(title)
                .setContentText(message).setSmallIcon(getNotificationIcon()).setDefaults(ntfyDefaults)
                .setContentIntent(contentIntent)
                //.setLargeIcon(R.drawable.notification)
                .setWhen(System.currentTimeMillis()).setTicker(message);

        notify(notification);

        //notification.flags |= PNNotification.FLAG_AUTO_CANCEL;

        //            Intent intent;
        //            if (uri != null
        //                    && uri.length() > 0
        //                    && (uri.startsWith("http:") || uri.startsWith("https:")
        //                            || uri.startsWith("tel:") || uri.startsWith("geo:"))) {
        //                intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        //            } else {
        //                String callbackActivityPackageName = sharedPrefs.getString(
        //                        Constants.CALLBACK_ACTIVITY_PACKAGE_NAME, "");
        //                String callbackActivityClassName = sharedPrefs.getString(
        //                        Constants.CALLBACK_ACTIVITY_CLASS_NAME, "");
        //                intent = new Intent().setClassName(callbackActivityPackageName,
        //                        callbackActivityClassName);
        //                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        //                intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        //            }

        //notification.setLatestEventInfo(context, title, message,
        //        contentIntent);
        //notificationManager.notify(random.nextInt(), notification);

        //            Intent clickIntent = new Intent(
        //                    Constants.ACTION_NOTIFICATION_CLICKED);
        //            clickIntent.putExtra(Constants.NOTIFICATION_ID, notificationId);
        //            clickIntent.putExtra(Constants.NOTIFICATION_API_KEY, apiKey);
        //            clickIntent.putExtra(Constants.NOTIFICATION_TITLE, title);
        //            clickIntent.putExtra(Constants.NOTIFICATION_MESSAGE, message);
        //            clickIntent.putExtra(Constants.NOTIFICATION_URI, uri);
        //            //        positiveIntent.setData(Uri.parse((new StringBuilder(
        //            //                "notif://notification.adroidpn.org/")).append(apiKey).append(
        //            //                "/").append(System.currentTimeMillis()).toString()));
        //            PendingIntent clickPendingIntent = PendingIntent.getBroadcast(
        //                    context, 0, clickIntent, 0);
        //
        //            notification.setLatestEventInfo(context, title, message,
        //                    clickPendingIntent);
        //
        //            Intent clearIntent = new Intent(
        //                    Constants.ACTION_NOTIFICATION_CLEARED);
        //            clearIntent.putExtra(Constants.NOTIFICATION_ID, notificationId);
        //            clearIntent.putExtra(Constants.NOTIFICATION_API_KEY, apiKey);
        //            //        negativeIntent.setData(Uri.parse((new StringBuilder(
        //            //                "notif://notification.adroidpn.org/")).append(apiKey).append(
        //            //                "/").append(System.currentTimeMillis()).toString()));
        //            PendingIntent clearPendingIntent = PendingIntent.getBroadcast(
        //                    context, 0, clearIntent, 0);
        //            notification.deleteIntent = clearPendingIntent;
        //
        //            notificationManager.notify(random.nextInt(), notification);

    } else {
        Log.w(LOGTAG, "Notificaitons disabled.");
    }

    datasource = new PNNotificationDataSource(context);
    datasource.open();
    datasource.createNotification(title, message, uri);
    datasource.close();

    //Update the list view

    if (MainActivity.instance != null) {
        MainActivity.instance.resetList();
    }

}

From source file:fr.itinerennes.ItineRennesApplication.java

/**
 * Inits ACRA and strict mode.// w w w . ja v a2s .co  m
 * 
 * @see android.app.Application#onCreate()
 */
@Override
public final void onCreate() {

    if (Conf.ACRA_ENABLED) {
        // The following line triggers the initialization of ACRA
        ACRA.init(this);
    }

    setupStrictMode();

    final Intent i = new Intent(this, LoadingActivity.class);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    startActivity(i);

    super.onCreate();
}

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

public void showPendingNotifications() {
    // Revision 74 changes the gesture model for Jelly Bean and above.
    // This flag is used to ensure they accept the notification of this
    // change.//  w ww  .j  ava  2s  . co m
    final boolean userMustAcceptGestureChange = mSharedPreferences
            .getBoolean(mService.getString(R.string.pref_must_accept_gesture_change_notification), false);

    if (userMustAcceptGestureChange) {
        // Build the intent for when the notification is clicked.
        final Intent notificationIntent = new Intent(mService, GestureChangeNotificationActivity.class);
        notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        notificationIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

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

From source file:com.silentcircle.contacts.utils.HelpUtils.java

/**
 * Prepares the help menu item by doing the following.
 * - If the helpUrlString is empty or null, the help menu item is made invisible.
 * - Otherwise, this makes the help menu item visible and sets the intent for the help menu
 *   item to view the URL./*from w  ww.j  av  a 2  s .c om*/
 *
 * @return returns whether the help menu item has been made visible.
 */
public static boolean prepareHelpMenuItem(Context context, MenuItem helpMenuItem, String helpUrlString) {
    if (TextUtils.isEmpty(helpUrlString)) {
        // The help url string is empty or null, so set the help menu item to be invisible.
        helpMenuItem.setVisible(false);

        // return that the help menu item is not visible (i.e. false)
        return false;
    } else {
        // The help url string exists, so first add in some extra query parameters.
        final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUrlString));

        // Then, create an intent that will be fired when the user
        // selects this help menu item.
        Intent intent = new Intent(Intent.ACTION_VIEW, fullUri);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

        // Set the intent to the help menu item, show the help menu item in the overflow
        // menu, and make it visible.
        helpMenuItem.setIntent(intent);
        MenuItemCompat.setShowAsAction(helpMenuItem, MenuItem.SHOW_AS_ACTION_NEVER);
        helpMenuItem.setVisible(true);

        // return that the help menu item is visible (i.e., true)
        return true;
    }
}

From source file:org.schabi.terminightor.NightKillerService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);

    if (intent != null) {
        Log.d(TAG, "get data from intent");
        try {/*from w ww  . j  ava 2  s  .  c  om*/
            alarm = Alarm.getFromCursorItem(AlarmDBOpenHelper.getAlarmDBOpenHelper(this)
                    .getReadableItem(intent.getLongExtra(Alarm.ID, -1)));
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (!alarm.isRepeatEnabled()) {
            alarm.setEnabled(false);
            AlarmDBOpenHelper.getAlarmDBOpenHelper(this).update(alarm);
        }

        indicator.saveAlarm(alarm);
    } else {
        Log.d(TAG, "get data from indicator");
        try {
            alarm = indicator.restoreAlarm(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = { 1000, 200, 200, 200 };
    if (alarm.isVibrate()) {
        vibrator.vibrate(pattern, 0);
    }

    mediaPlayer = setupNewMediaPlayer(alarm);
    mediaPlayer.start();

    alarmActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
            | Intent.FLAG_FROM_BACKGROUND);
    alarmActivityIntent.putExtra(Alarm.ID, alarm.getId());
    alarmActivityIntent.putExtra(Alarm.NAME, alarm.getName());
    alarmActivityIntent.putExtra(Alarm.NFC_TAG_ID, alarm.getNfcTagId());
    this.startActivity(alarmActivityIntent);

    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Notification n = new NotificationCompat.Builder(this).setContentTitle(getString(R.string.alarm))
            .setContentText(alarm.getName()).setSmallIcon(R.drawable.terminightor_notify_small).setOngoing(true)
            .build();
    n.contentIntent = PendingIntent.getActivity(this.getApplicationContext(),
            SpecialPendingIds.OPEN_ALARM_ACTIVITY, alarmActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    nm.notify(NOTIFICATION_ID, n);

    return START_STICKY;
}

From source file:com.tasomaniac.openwith.resolver.ResolverActivity.java

private Intent makeMyIntent() {
    Intent intent = new Intent(getIntent());
    intent.setComponent(null);/* ww w . j a  v  a  2 s.  c  o  m*/
    // The resolver activity is set to be hidden from recent tasks.
    // we don't want this attribute to be propagated to the next activity
    // being launched.  Note that if the original Intent also had this
    // flag set, we are now losing it.  That should be a very rare case
    // and we can live with this.
    intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    return intent;
}

From source file:com.google.android.car.kitchensink.bluetooth.MapMceTestFragment.java

void launchDevicePicker() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(BluetoothDevicePicker.ACTION_DEVICE_SELECTED);
    getContext().registerReceiver(mPickerReceiver, filter);

    Intent intent = new Intent(BluetoothDevicePicker.ACTION_LAUNCH);
    intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    getContext().startActivity(intent);/*from w w  w .  ja  v  a2  s .  co m*/
}

From source file:com.google.android.car.kitchensink.bluetooth.BluetoothHeadsetFragment.java

void launchDevicePicker() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(BluetoothDevicePicker.ACTION_DEVICE_SELECTED);
    getContext().registerReceiver(mPickerReceiver, filter);

    Intent intent = new Intent(DEVICE_PICKER_ACTION);
    intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    getContext().startActivity(intent);// w ww .j av a 2 s. co  m
}