Example usage for android.content Intent FLAG_ACTIVITY_CLEAR_TASK

List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TASK

Introduction

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

Prototype

int FLAG_ACTIVITY_CLEAR_TASK

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

Click Source Link

Document

If set in an Intent passed to Context#startActivity Context.startActivity() , this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started.

Usage

From source file:mx.itesm.logistics.vehicle_tracking.activity.LoginActivity.java

protected void launchMainActivity() {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(/*from   w ww.  j a va2s  .  co m*/
            Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    startActivity(intent);
}

From source file:org.hansel.myAlert.Login.java

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

    //buscamos si quedo en un paso del registro y no termino
    int step = PreferenciasHancel.getCurrentWizardStep(getApplicationContext());
    switch (step) {
    case Util.REGISTRO_PASO_2:
        Intent step2 = new Intent(getApplicationContext(), ConfigContactsActivity.class);
        step2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        step2.putExtra("registro", true);
        startActivity(step2);/*from www .  jav a2 s.  c o m*/
        finish();
        return;
    case Util.REGISTRO_PASO_3:
        Intent step3 = new Intent(getApplicationContext(), PreferenceOng.class);
        step3.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        step3.putExtra("registro", true);
        startActivity(step3);
        finish();
        return;
    default:
        break;
    }
    if (PreferenciasHancel.getLoginOk(getApplicationContext())) {
        Intent i = new Intent(getApplicationContext(), MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(i);
        finish();
    }

    user = (EditText) findViewById(R.id.txtUser);
    passwd = (EditText) findViewById(R.id.txtPassword);
    Button btnLogin = (Button) findViewById(R.id.btnLogin);
    btnLogin.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            AttempLogin();
        }
    });

    TextView txt = (TextView) findViewById(R.id.link_to_register);
    txt.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), Registro.class);
            startActivity(i);
        }
    });

    errores = (TextView) findViewById(R.id.tvError);
    mLoginFormView = findViewById(R.id.login_form1);
    mLoginStatusView = findViewById(R.id.login_status1);
    mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message1);

    ViewPager mpager = (ViewPager) findViewById(R.id.pager);
    PagerAdapter mpagerAdapter = new ScreenSlidePageAdapter(getSupportFragmentManager());
    mpager.setAdapter(mpagerAdapter);
    CirclePageIndicator indicator = (CirclePageIndicator) findViewById(R.id.pagerIndicator);
    indicator.setViewPager(mpager);

}

From source file:mx.itesm.logistics.crew_tracking.activity.LoginActivity.java

protected void launchMainActivity() {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
    startActivity(intent);// w w  w .  jav a  2s.co  m
}

From source file:com.example.android.appnavigation.app.NotificationsActivity.java

public void onPostInterstitial(View v) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setTicker("Interstitial Notification").setSmallIcon(android.R.drawable.stat_notify_chat)
            .setContentTitle("Interstitial Notification").setContentText("This will show a detail page")
            .setAutoCancel(true).setContentIntent(
                    PendingIntent.getActivity(this, 0, new Intent(this, InterstitialMessageActivity.class)
                            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK), 0));
    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nm.notify("interstitial_tag", R.id.interstitial_notification, builder.getNotification());
}

From source file:id.satusatudua.sigap.ui.UpdatePasswordActivity.java

@Override
public void onPasswordUpdated(User currentUser) {
    new AlertDialog.Builder(this).setIcon(R.mipmap.ic_launcher).setTitle(R.string.app_name).setCancelable(false)
            .setMessage("Kata sandi anda berhasil diubah!").setPositiveButton("OK", (dialog, which) -> {
                Intent intent = new Intent(this, TombolActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);/*w  w  w  .ja v  a 2s.co  m*/
            }).show().getButton(DialogInterface.BUTTON_POSITIVE)
            .setTextColor(ContextCompat.getColor(this, R.color.colorPrimary));
}

From source file:com.dgsd.android.ShiftTracker.Service.NotificationService.java

private void showAlarmNotification(Shift shift) {
    if (shift == null)
        return;/*from w w w  .j a  v a2  s. c  om*/

    try {
        NotificationCompat.Builder b = new NotificationCompat.Builder(this);
        b.setAutoCancel(true);
        b.setPriority(NotificationCompat.PRIORITY_HIGH);
        b.setDefaults(Notification.DEFAULT_ALL);
        b.setTicker("Reminder: " + shift.name);
        b.setSmallIcon(R.drawable.stat_notify_calendar);
        b.setContentTitle(shift.name);
        b.setContentText(getContentText(shift));
        b.setWhen(shift.getStartTime());

        final Intent contentIntent = new Intent(this, EditShiftActivity.class);
        contentIntent.putExtra(EditShiftActivity.EXTRA_SHIFT, shift);
        contentIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        b.setContentIntent(PendingIntent.getActivity(this, shift.hashCode(), contentIntent,
                PendingIntent.FLAG_UPDATE_CURRENT));

        notify(Tag.REMINDER, (int) shift.id, b.build());
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "Error creating event reminder notification", e);
        }
    }

}

From source file:androidx.navigation.NavDeepLinkBuilder.java

/**
 * Construct a new NavDeepLinkBuilder./*w  w  w  . ja  v  a 2s .c  o m*/
 *
 * If the context passed in here is not an {@link Activity}, this method will use
 * {@link android.content.pm.PackageManager#getLaunchIntentForPackage(String)} as the
 * default activity to launch, if available.
 *
 * @param context Context used to create deep links
 * @see #setComponentName
 */
public NavDeepLinkBuilder(@NonNull Context context) {
    mContext = context;
    if (mContext instanceof Activity) {
        mIntent = new Intent(mContext, mContext.getClass());
    } else {
        Intent launchIntent = mContext.getPackageManager().getLaunchIntentForPackage(mContext.getPackageName());
        mIntent = launchIntent != null ? launchIntent : new Intent();
    }
    mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
}

From source file:com.parse.loginsample.withdispatchactivity.SampleProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_profile);
    titleTextView = (TextView) findViewById(R.id.profile_title);
    emailTextView = (TextView) findViewById(R.id.profile_email);
    nameTextView = (TextView) findViewById(R.id.profile_name);
    titleTextView.setText(R.string.profile_title_logged_in);

    findViewById(R.id.logout_button).setOnClickListener(new OnClickListener() {
        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        @Override//  ww w .j  a va 2 s . c  o m
        public void onClick(View v) {
            ParseUser.logOut();

            // FLAG_ACTIVITY_CLEAR_TASK only works on API 11, so if the user
            // logs out on older devices, we'll just exit.
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                Intent intent = new Intent(SampleProfileActivity.this, SampleDispatchActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            } else {
                finish();
            }
        }
    });

    getFbEvents();
}

From source file:id.satusatudua.sigap.ui.SetPasswordActivity.java

@Override
public void onPasswordUpdated(User currentUser) {
    new AlertDialog.Builder(this).setIcon(R.mipmap.ic_launcher).setTitle(R.string.app_name).setCancelable(false)
            .setMessage(// w  w  w .  jav a  2 s  .c  o m
                    "Sebelum anda dapat menggunakan fitur Sigap, anda harus memasukan minimal 3 pengguna lain yang anda percayai. Silahkan masukan pengguna yang anda percayai di halaman berikutnya!")
            .setPositiveButton("OK", (dialog, which) -> {
                Intent intent = new Intent(this, AddTrustedUserActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
            }).show().getButton(DialogInterface.BUTTON_POSITIVE)
            .setTextColor(ContextCompat.getColor(this, R.color.colorPrimary));
}

From source file:com.commonsware.android.backup.RestoreRosterFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    String url = BuildConfig.URL_SERVER + adapter.getItem(position).dataset;
    Intent i = new Intent(getActivity(), RestoreProgressActivity.class).setData(Uri.parse(url))
            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
                    | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

    startActivity(i);/*from  ww w.  j  a  va  2s  . c o  m*/
}