Example usage for android.support.v4.content IntentCompat FLAG_ACTIVITY_CLEAR_TASK

List of usage examples for android.support.v4.content IntentCompat FLAG_ACTIVITY_CLEAR_TASK

Introduction

In this page you can find the example usage for android.support.v4.content IntentCompat FLAG_ACTIVITY_CLEAR_TASK.

Prototype

int FLAG_ACTIVITY_CLEAR_TASK

To view the source code for android.support.v4.content IntentCompat 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:Main.java

public static void sendEmail(Context context, String receiver, String subject, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { receiver });
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    try {//from   ww w . j ava 2s .  com
        context.startActivity(Intent.createChooser(intent, "Send mail..."));
    } catch (android.content.ActivityNotFoundException ex) {
    }
}

From source file:com.fanfou.app.opensource.util.IntentHelper.java

public static void goLoginPage(final Context context) {
    final Intent intent = new Intent(context, LoginPage.class);
    intent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);/*from  w  ww. j  a  v a 2  s . com*/
}

From source file:in.codehex.facilis.SplashActivity.java

/**
 * Implement and manipulate the objects.
 *//* w  ww  .ja va2s. c  o m*/
private void prepareObjects() {
    if (userPreferences.contains(Config.KEY_PREF_TOKEN)) {
        // TODO: load view orders and then open main activity
        mIntent = new Intent(SplashActivity.this, MainActivity.class);
        mIntent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(mIntent);
    } else {
        mIntent = new Intent(SplashActivity.this, LoginActivity.class);
        mIntent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(mIntent);
    }
}

From source file:com.doplgangr.secrecy.OutgoingCallReceiver.java

@Override
public void onReceive(final Context context, Intent intent) {

    // Gets the intent, check if it matches our secret code
    if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction()) && intent.getExtras() != null) {
        Intent launcher = new Intent(context, MainActivity_.class);
        //These flags are added to make the new mainActivity in the home stack.
        //i.e. back button returns to home not dialer.
        launcher.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK
                | IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
        String phoneNumber = intent.getExtras().getString(android.content.Intent.EXTRA_PHONE_NUMBER);
        if (Pref.OpenPIN().exists())
            if (("*#" + Pref.OpenPIN().get()).equals(phoneNumber))
                // Launch the main app!!
                launchActivity(context, launcher);
    }/*  w  w  w . j av a2  s. c o m*/
}

From source file:augsburg.se.alltagsguide.settings.SettingsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // Respond to the action bar's Up/Home button
    case android.R.id.home:
        Intent intent = new Intent(this, OverviewActivity.class);
        intent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);/* ww  w  . j  a  va  2s.  co m*/
        finish();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:augsburg.se.alltagsguide.settings.SettingsActivity.java

@Override
public void onBackPressed() {
    Intent intent = new Intent(this, OverviewActivity.class);
    intent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);//from   w  w  w.j  a  v a  2 s.co  m
    finish();
}

From source file:org.exoplatform.accountswitcher.AccountSwitcherActivity.java

/**
 * Redirect to the HomeActivity (Home screen)
 *//*  w ww.j a  va 2  s .  c o  m*/
public void redirectToHomeScreenAndFinish() {
    Intent home = new Intent(this, HomeActivity.class);
    // IntentCompat.FLAG_ACTIVITY_CLEAR_TASK works only from API_VERSION>=11
    home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
            | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
    startActivity(home);
    finish();
}

From source file:augsburg.se.alltagsguide.start.WelcomeActivity.java

private void startOverview() {
    Intent intent = new Intent(WelcomeActivity.this, OverviewActivity.class);
    intent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);/*from ww w .  j  av a 2  s .co  m*/
    finish();
}

From source file:in.codehex.facilis.ForgotPasswordActivity.java

/**
 * Implement and manipulate the objects.
 *//*from  w w  w.  j a va  2s  .  co m*/
private void prepareObjects() {
    mProgressDialog.setMessage("Resetting password..");
    mProgressDialog.setCancelable(false);

    btnResetPass.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String mail = editEmail.getText().toString().trim();
            if (TextUtils.isEmpty(mail))
                editEmail.setError(getString(R.string.error_email_empty));
            else if (!isValidEmail(mail))
                editEmail.setError(getString(R.string.error_email_invalid));

            if (!TextUtils.isEmpty(mail) && isValidEmail(mail))
                processForgotPass(mail);
        }
    });

    textBackLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mIntent = new Intent(ForgotPasswordActivity.this, LoginActivity.class);
            mIntent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(mIntent);
        }
    });
}

From source file:org.exoplatform.accountswitcher.AccountSwitcherActivity.java

/**
 * Redirect to the LoginActivity (Authenticate screen)
 *//*from  w w w.j  av  a  2s .c  o  m*/
public void redirectToLoginScreenAndFinish() {
    Intent login = new Intent(this, LoginActivity.class);
    // IntentCompat.FLAG_ACTIVITY_CLEAR_TASK works only from API_VERSION>=11
    login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
            | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
    startActivity(login);
    finish();
}