Example usage for android.content Intent FLAG_ACTIVITY_NEW_TASK

List of usage examples for android.content Intent FLAG_ACTIVITY_NEW_TASK

Introduction

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

Prototype

int FLAG_ACTIVITY_NEW_TASK

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

Click Source Link

Document

If set, this activity will become the start of a new task on this history stack.

Usage

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/*from  ww w .ja 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:com.gigathinking.simpleapplock.ResetUnlockMethod.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_reset);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    mDialog = new ProgressDialog(this, ProgressDialog.STYLE_SPINNER);
    mDialog.setIndeterminate(true);/*from  w w  w . j av  a2s  .co m*/
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    mResetReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            prefs.edit().putString(AppLockApplication.LOCKTYPE, AppLockApplication.LOCKTYPE_PIN).commit();
            prefs.edit()
                    .putString(AppLockApplication.PASSWORD, intent.getStringExtra(AppLockApplication.PASSWORD))
                    .commit();
            Toast.makeText(context, getString(R.string.pin_reset), Toast.LENGTH_LONG).show();
            startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)
                    .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
            //startActivity(new Intent(ResetUnlockMethod.this,UnlockWithPIN.class).putExtra("test","test"));
            finish();
        }
    };
    LocalBroadcastManager.getInstance(this).registerReceiver(mResetReceiver,
            new IntentFilter(AppLockApplication.RESET_UNLOCK));

    if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.register_complete),
            false)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(getString(R.string.reset_register_device));
        builder.setTitle(getString(R.string.info));
        builder.setPositiveButton(getString(R.string.register), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                new Register().execute();
                if (mDialog != null) {
                    mDialog.setMessage(getString(R.string.register_ongoing));
                    mDialog.show();
                }
                dialog.dismiss();
            }
        });
        builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_HOME);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }
        });
        builder.create().show();
    } else {
        if (mDialog != null) {
            mDialog.setMessage(getString(R.string.connect_to_server));
            mDialog.show();
        }
        new DoRequestReset().execute();
    }
}

From source file:com.nbos.phonebook.sync.syncadapter.SyncAdapter.java

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {//from w  ww  .  j  av  a2s .  co m
    if (isSyncing) {
        Log.i(tag, "isSyncing, returning");
        return;
    }
    isSyncing = true;
    this.account = account;
    try {
        // use the account manager to request the credentials
        String phoneNumber = accountManager.getUserData(account, Constants.PHONE_NUMBER_KEY);
        authtoken = accountManager.blockingGetAuthToken(account, Constants.AUTHTOKEN_TYPE,
                true /* notifyAuthFailure */);
        Log.i(tag, "phone number is: " + phoneNumber + ", authtoken: " + authtoken);
        // fetch updates from the sample service over the cloud
        boolean valid = Net.checkValidAccount(account, authtoken,
                accountManager.getUserData(account, Constants.PHONE_NUMBER_KEY));
        // start the confirmation activity if not valid

        Log.i(tag, "valid account is: " + valid);
        if (!valid) {
            final Intent intent = new Intent(context, ValidationActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra(Net.PARAM_USERNAME, account.name);
            intent.putExtra(Net.PARAM_PASSWORD, authtoken);
            intent.putExtra(Net.PARAM_PHONE_NUMBER, phoneNumber);
            intent.putExtra(Net.PARAM_PHONE_NUMBER, phoneNumber);
            context.startActivity(intent);
            isSyncing = false;
            return;
        }
        doSync();
    } catch (Exception e) {
        notifyListeners(e.getMessage());
        e.printStackTrace();
    } finally {
        isSyncing = false;
    }
}

From source file:gov.nasa.arc.geocam.talk.UIUtils.java

/**
 * Go to the {@link GeoCamTalkCreateActivity} activity to create a new GeoCam Talk Message.
 *
 * @param context The activity context to send the intent from.
 *///from w  ww  .  ja  va 2  s  . co  m
public static void createTalkMessage(Context context) {
    final Intent intent = new Intent(context, GeoCamTalkCreateActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

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

/**
 * Implement and manipulate the objects.
 *///from  w w w  .j a  v a2s.  c  om
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:com.adguard.android.commons.BrowserUtils.java

public static void openSamsungBlockingOptions(Context context) {
    Intent intent = new Intent();
    intent.setAction(SAMSUNG_CONTENT_BLOCKER_ACTION);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
            PackageManager.MATCH_DEFAULT_ONLY);
    if (list.size() > 0) {
        boolean found = false;
        for (ResolveInfo info : list) {
            if (info.activityInfo.packageName.contains(SAMSUNG_PACKAGE_PREFIX)
                    || info.activityInfo.packageName.contains(SAMSUNG)) {
                found = true;/* www. ja  va  2 s .com*/
                intent.setClassName(info.activityInfo.packageName, info.activityInfo.name);
            }
        }
        if (found) {
            context.startActivity(intent);
        }
    }
}

From source file:de.jamoo.muzei.WallSource.java

@Override
public void onCustomCommand(int id) {
    super.onCustomCommand(id);

    if (id == COMMAND_ID_SHARE) {
        Artwork currentArtwork = getCurrentArtwork();
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");

        Uri artUrl = currentArtwork.getImageUri();
        if (DEBUG)
            Log.d(TAG, "artUrl: " + artUrl);

        String author = currentArtwork.getByline();
        if (DEBUG)
            Log.d(TAG, "author: " + author);

        String playUrl = "http://play.google.com/store/apps/details?id=" + getPackageName();
        if (DEBUG)
            Log.d(TAG, "playUrl: " + playUrl);

        shareIntent.putExtra(Intent.EXTRA_TEXT,
                "My wallpaper today is " + currentArtwork.getTitle() + " by " + author + " \n" + artUrl + " \n"
                        + "from the " + getString(R.string.app_name) + " app\n"
                        + "Get it now on the PlayStore! " + playUrl);

        shareIntent = Intent.createChooser(shareIntent, "Share Wallpaper");
        shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(shareIntent);/*from  w w  w . ja v  a 2  s . c o m*/
    }
}

From source file:fr.cph.stock.android.StockTrackerApp.java

/**
 * This function loads the error activity to the screen. It happens usually when the session is timeout and needs to request a
 * new session id to the server//from   w w w. j ava 2s.c o m
 * 
 * @param currentActivity
 *            the activity to stop
 * @param jsonObject
 *            the json object containing the error message
 */
public void loadErrorActivity(Activity currentActivity, JSONObject jsonObject) {
    Intent intent = new Intent(this, ErrorActivity.class);
    intent.putExtra("data", jsonObject.toString());
    SharedPreferences settings = getSharedPreferences(BaseActivity.PREFS_NAME, 0);
    String login = settings.getString("login", null);
    String password = settings.getString("password", null);
    intent.putExtra("login", login);
    intent.putExtra("password", password);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    currentActivity.finish();
}

From source file:com.fangyuan.vpngate.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_refresh:
        refresh();/*  ww  w.j  a va  2  s . c  o m*/
        break;

    case R.id.menu_setting:
        Intent intent = new Intent(this, SettingsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.insthub.O2OMobile.Activity.ReceiveOrderDialogActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dialog_layout);
    show_message = getIntent().getStringExtra(CUSTOM_CONTENT);

    dialog_message = (TextView) findViewById(R.id.dialog_message);

    positive = (TextView) findViewById(R.id.yes);
    negative = (TextView) findViewById(R.id.no);

    JSONObject jsonObject = null;//from w w  w .ja v  a2s. com
    try {
        jsonObject = new JSONObject(show_message);

        final PUSH_MESSAGE message1 = new PUSH_MESSAGE();
        message1.fromJson(jsonObject);
        dialog_message.setText(message1.content + getString(R.string.look_up_or_not));

        positive.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                if (message1.type == ENUM_MESSAGE_TYPE.ORDER.value()) {

                    Intent it = new Intent(ReceiveOrderDialogActivity.this, D1_OrderActivity.class);
                    it.putExtra(D1_OrderActivity.ORDER_ID, message1.order_id);
                    it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    ReceiveOrderDialogActivity.this.startActivity(it);
                    (ReceiveOrderDialogActivity.this).overridePendingTransition(R.anim.push_right_in,
                            R.anim.push_right_out);
                }

                finish();
            }
        });

        negative.setOnClickListener(new View.OnClickListener() {

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

    } catch (JSONException e) {
        e.printStackTrace();
    }

}