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.decad3nce.aegis.AegisActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        return true;
    case R.id.settings:
        Intent settingsIntent = new Intent(AegisActivity.this, AdvancedSettingsActivity.class);
        settingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        settingsIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        startActivity(settingsIntent);/*from ww w  .  j ava 2s.com*/
        return true;
    case R.id.licenses:
        Intent initialIntent = new Intent(AegisActivity.this, InitializationActivity.class);
        initialIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        initialIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        startActivity(initialIntent);
        return true;
    case R.id.about:
        Intent aboutIntent = new Intent(AegisActivity.this, AboutActivity.class);
        aboutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        aboutIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        startActivity(aboutIntent);
        return true;
    }

    return false;
}

From source file:com.asksven.betterbatterystats.PackageFragmentActivity.java

public static void showAppOps(Context context, String packageName) {

    Intent intent = null;//from w ww  .  j a  v  a  2 s .c  o  m
    // JB
    if (Build.VERSION.SDK_INT == 18) {
        intent = new Intent("android.settings.APP_OPS_SETTINGS");
        Uri uri = Uri.fromParts(SCHEME, packageName, null);
    } else if (Build.VERSION.SDK_INT >= 19) {
        // @see http://brightechno.com/blog/archives/211
        intent = new Intent();
        intent.setClassName("com.android.settings", "com.android.settings.Settings");
        intent.setAction(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
                | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        intent.putExtra(":android:show_fragment", "com.android.settings.applications.AppOpsSummary");
    }

    if (intent != null) {
        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(context, context.getString(R.string.message_no_appops), Toast.LENGTH_SHORT).show();
        }

    }
}

From source file:org.android.gcm.client.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    final SharedPreferences prefs = getSharedPreferences("gcmclient", Context.MODE_PRIVATE);
    pushpak = prefs.getString("push_pak", "");
    pushact = prefs.getString("push_act", "");
    final boolean pushon = prefs.getBoolean("push_on", true);
    final boolean pushnotif = prefs.getBoolean("push_notification", true);

    if (pushnotif) {
        final String notifact = prefs.getString("notification_act", "");
        Bundle extras = intent.getExtras();
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
        // The getMessageType() intent parameter must be the intent you received
        // in your BroadcastReceiver.
        String messageType = gcm.getMessageType(intent);

        // Send a notification.
        if (!extras.isEmpty()) { // has effect of unparcelling Bundle
            /*//from   w w  w  . j  ava  2s  .  c  o m
             * Filter messages based on message type. Since it is likely that GCM will be
             * extended in the future with new message types, just ignore any message types you're
             * not interested in, or that you don't recognize.
             */
            if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
                sendNotification(getString(R.string.send_error) + ": " + extras.toString(), notifact);
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
                sendNotification(getString(R.string.deleted) + ": " + extras.toString(), notifact);
                // If it's a regular GCM message, do some work.
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                // Post notification of received message.
                sendNotification(
                        getString(R.string.received, extras.getString("name"), extras.getString("num")),
                        notifact);
                Log.i(TAG, "Received: " + extras.toString());
            }
        }
    }

    // End if push is not enabled.
    if (!pushon) {
        // Release the wake lock provided by the WakefulBroadcastReceiver.
        GcmBroadcastReceiver.completeWakefulIntent(intent);
        return;
    }

    final boolean fullwake = prefs.getBoolean("full_wake", false);
    final boolean endoff = prefs.getBoolean("end_off", true);

    // Manage the screen.
    PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock mWakeLock = mPowerManager
            .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
    boolean misScreenOn = mPowerManager.isScreenOn();
    int mScreenTimeout = 0;
    if (!misScreenOn) {
        if (endoff) {
            // Change the screen timeout setting.
            mScreenTimeout = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT,
                    0);
            if (mScreenTimeout != 0) {
                Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 3000);
            }
        }
        // Full wake lock
        if (fullwake) {
            mWakeLock.acquire();
        }
    }

    // Start the activity.
    try {
        startActivity(getPushactIntent(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NO_ANIMATION
                | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS));
        // Wait to register.
        Thread.sleep(REGISTER_DURATION);
    } catch (android.content.ActivityNotFoundException e) {
        RING_DURATION = 0;
        Log.i(TAG, "Activity not started");
    } catch (InterruptedException e) {
    }

    // Release the wake lock.
    if (!misScreenOn && fullwake) {
        mWakeLock.release();
    }
    GcmBroadcastReceiver.completeWakefulIntent(intent);

    // Restore the screen timeout setting.
    if (endoff && mScreenTimeout != 0) {
        try {
            Thread.sleep(RING_DURATION);
        } catch (InterruptedException e) {
        }
        Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, mScreenTimeout);
    }
}

From source file:net.xisberto.work_schedule.alarm.AlarmMessageActivity.java

private void showNotification() {
    Intent alarmIntent = new Intent(this, AlarmMessageActivity.class);
    alarmIntent.setAction(AlarmMessageActivity.ACTION_SHOW_ALARM);
    alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

    PendingIntent alarmSender = PendingIntent.getActivity(this, period.getId(), alarmIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    Intent dismissIntent = new Intent(this, AlarmMessageActivity.class)
            .setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).setAction(ACTION_DISMISS_ALARM);
    PendingIntent dismissSender = PendingIntent.getActivity(this, REQ_DISMISS, dismissIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    Intent snoozeIntent = new Intent(this, AlarmMessageActivity.class)
            .setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).setAction(ACTION_SNOOZE_ALARM);
    PendingIntent snoozeSender = PendingIntent.getActivity(this, REQ_SNOOZE, snoozeIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationManager nm = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    Notification notification = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_notification).setContentTitle(this.getString(period.getLabelId()))
            .setTicker(this.getString(period.getLabelId())).setWhen(period.time.getTimeInMillis())
            .setOngoing(false).setOnlyAlertOnce(true).setContentIntent(alarmSender)
            .setDeleteIntent(dismissSender)
            .addAction(R.drawable.ic_snooze, getString(R.string.snooze), snoozeSender)
            .addAction(R.drawable.ic_dismiss, getString(R.string.dismiss), dismissSender).build();

    nm.notify(period.getId(), notification);
}

From source file:com.silentcircle.contacts.activities.ScContactDetailActivity.java

@Override
protected void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
        // This activity must not be shown. We have to select the contact in the
        // PeopleActivity instead ==> Create a forward intent and finish
        final Intent originalIntent = getIntent();
        Intent intent = new Intent();
        intent.setAction(originalIntent.getAction());
        intent.setDataAndType(originalIntent.getData(), originalIntent.getType());

        // If we are launched from the outside, we should create a new task, because the user
        // can freely navigate the app (this is different from phones, where only the UP button
        // kicks the user into the full app)
        if (NavUtils.shouldUpRecreateTask(this, intent)) {
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
                    | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
        } else {/*  w w  w . j  a  va  2s  .  c  o  m*/
            intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT
                    | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        }

        intent.setClass(this, ScContactsMainActivity.class);
        startActivity(intent);
        finish();
        return;
    }

    setContentView(R.layout.contact_detail_activity);

    mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState,
            getSupportFragmentManager(), null, findViewById(R.id.contact_detail_container),
            mContactDetailFragmentListener);

    // We want the UP affordance but no app icon.
    // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick.
    ActionBar actionBar = this.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE,
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME);
        actionBar.setTitle("");
    }

    Log.i(TAG, getIntent().getData().toString());
}

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

public void notify(String notificationId, String apiKey, String title, String message, String uri,
        String imageUrl) {//from www .j av  a  2  s.c o  m
    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();
        }
        mBuilder.setWhen(System.currentTimeMillis())//?
                .setPriority(Notification.PRIORITY_DEFAULT)//
                //            .setAutoCancel(true)//?????
                .setOngoing(false)//ture???,??(?)???,?(,??,)
                .setDefaults(Notification.DEFAULT_VIBRATE)//???????defaults??
                //Notification.DEFAULT_ALL  Notification.DEFAULT_SOUND  // requires VIBRATE permission
                .setSmallIcon(getNotificationIcon());

        mBuilder.setAutoCancel(true)//?
                .setContentTitle(title).setContentText(message).setTicker(message);
        // Notification
        if (isNotificationSoundEnabled()) {
            mBuilder.setDefaults(Notification.DEFAULT_SOUND);
        }
        if (isNotificationVibrateEnabled()) {
            mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
        }
        mBuilder.setOnlyAlertOnce(true);

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

        Intent intent = new Intent(context, NotificationDetailsActivity.class);
        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.putExtra(Constants.NOTIFICATION_IMAGE_URL, imageUrl);

        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, random.nextInt(), intent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        mBuilder.setContentIntent(contentIntent);
        notificationManager.notify(random.nextInt(), mBuilder.build());

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

From source file:br.gbizotto.customcamera.camera2.Camera2BasicFragment.java

@Override
public void pictureSaved(String filePath) {
    Intent intent = new Intent(getActivity(), ReviewPictureActivity.class);
    intent.putExtra("filePath", filePath);
    intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS).addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    startActivity(intent);//from   w  w w  .  ja v a 2 s  .  c  om
}

From source file:com.android.contacts.activities.ContactDetailActivity.java

/** @} */

@Override//from w w w .  j a  v a2  s .com
protected void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    LogUtils.i(TAG, "[onCreate][launch]start");
    ///M: Bug Fix for ALPS01022809,JE happens when click the favourite video to choose contact in tablet
    registerPHBReceiver();
    mIsActivitFinished = false;
    /** M: Bug Fix for ALPS00393950 @{ */
    boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this);
    if (!isUsingTwoPanes) {
        SetIndicatorUtils.getInstance().registerReceiver(this);
    }
    /** @} */
    if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
        // This activity must not be shown. We have to select the contact in the
        // PeopleActivity instead ==> Create a forward intent and finish
        final Intent originalIntent = getIntent();
        Intent intent = new Intent();
        intent.setAction(originalIntent.getAction());
        intent.setDataAndType(originalIntent.getData(), originalIntent.getType());

        // If we are launched from the outside, we should create a new task, because the user
        // can freely navigate the app (this is different from phones, where only the UP button
        // kicks the user into the full app)
        if (shouldUpRecreateTask(intent)) {
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        } else {
            intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT
                    | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        }
        intent.setClass(this, PeopleActivity.class);
        startActivity(intent);
        LogUtils.i(TAG, "onCreate(),Using Two Panes...finish Actiivity..");
        finish();
        return;
    }

    setContentView(R.layout.contact_detail_activity);

    mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getFragmentManager(),
            null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener);

    // We want the UP affordance but no app icon.
    // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick.
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        ///@Modify for add Customer view{
        actionBar.setDisplayOptions(
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM,
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
                        | ActionBar.DISPLAY_SHOW_CUSTOM);
        ///@}
        actionBar.setTitle("");
    }

    Log.i(TAG, getIntent().getData().toString());
    /** M: New Feature xxx @{ */
    //M:fix CR:ALPS00958663,disconnect to smartbook when contact screen happen JE
    if (getIntent() != null && getIntent().getData() != null) {
        mSimOrPhoneUri = getIntent().getData();
        Log.i(TAG, "mSimOrPhoneUri = " + mSimOrPhoneUri);
    } else {
        Log.e(TAG, "Get intent data error getIntent() = " + getIntent());
    }
    /// M: @ CT contacts detail history set listener{
    ExtensionManager.getInstance().getContactDetailEnhancementExtension().configActionBarExt(getActionBar(),
            ContactPluginDefault.COMMD_FOR_OP09);
    /// @}
    LogUtils.i(TAG, "[onCreate][launch]end");
}

From source file:com.crearo.gpslogger.ui.fragments.display.GpsSimpleViewFragment.java

private void startInstalledAppDetailsActivity(final Activity context) {
    if (context == null) {
        return;//from   ww w.ja  v a 2 s  . co  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.sportsapp.MainActivity.java

private void openAppDetails() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(// ww  w.  ja  va2 s .  c  o m
            "? Camera?  ? ? -> ??? ?");
    builder.setPositiveButton("?", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent();
            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            intent.setData(Uri.parse("package:" + getPackageName()));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            startActivity(intent);
        }
    });
    builder.setNegativeButton("?", null);
    builder.show();
}