Example usage for android.content Intent FLAG_ACTIVITY_NO_HISTORY

List of usage examples for android.content Intent FLAG_ACTIVITY_NO_HISTORY

Introduction

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

Prototype

int FLAG_ACTIVITY_NO_HISTORY

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

Click Source Link

Document

If set, the new activity is not kept in the history stack.

Usage

From source file:org.xbmc.android.remote.presentation.activity.MovieLibraryActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // first, process individual menu events
    switch (mTabHost.getCurrentTab()) {
    case 0://from w  w  w  .  java  2  s .com
        mMovieController.onOptionsItemSelected(item);
        break;
    case 1:
        mActorController.onOptionsItemSelected(item);
        break;
    case 2:
        mGenresController.onOptionsItemSelected(item);
        break;
    case 3:
        mFileController.onOptionsItemSelected(item);
        break;
    case 4:
        mMoviePosterWrapController.onOptionsItemSelected(item);
        break;
    }

    // then the generic ones.
    switch (item.getItemId()) {
    case MENU_REMOTE:
        final Intent intent;
        if (getSharedPreferences("global", Context.MODE_PRIVATE).getInt(RemoteController.LAST_REMOTE_PREFNAME,
                -1) == RemoteController.LAST_REMOTE_GESTURE) {
            intent = new Intent(this, GestureRemoteActivity.class);
        } else {
            intent = new Intent(this, RemoteActivity.class);
        }
        intent.addFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(intent);
        return true;
    case MENU_UPDATE_LIBRARY:
        mMovieController.refreshMovieLibrary(this);
        return true;
    case MENU_NOW_PLAYING:
        startActivity(new Intent(this, NowPlayingActivity.class));
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:fm.smart.r1.activity.ItemActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem menu_item) {
    switch (menu_item.getItemId()) {
    case CREATE_EXAMPLE_ID: {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClassName(this, CreateExampleActivity.class.getName());
        Utils.putExtra(intent, "item_id", (String) item.item_node.atts.get("id"));
        Utils.putExtra(intent, "cue", item.cue_text);
        Utils.putExtra(intent, "example_language",
                Utils.INV_LANGUAGE_MAP.get(item.cue_node.atts.get("language").toString()));
        Utils.putExtra(intent, "translation_language",
                Utils.INV_LANGUAGE_MAP.get(item.response_node.atts.get("language").toString()));
        startActivity(intent);/* w  w  w .  ja va  2 s  .  com*/
        break;
    }
    case CREATE_SOUND_ID: {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClassName(this, CreateSoundActivity.class.getName());
        Utils.putExtra(intent, "item_id", (String) item.item_node.atts.get("id"));
        startActivity(intent);
        break;
    }
    case ADD_TO_LIST_ID: {
        // TODO inserting login request here more complicated in as much as
        // this is not an activity we can simply return to with parameters
        // although we could jump to this from switch in onCreate
        // of course there's probably a swish URI way to call, but may take
        // time to get it just right ...
        // or should just bring them back and open menu bar ...
        if (Main.isNotLoggedIn(this)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(this, LoginActivity.class.getName());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
            // navigation
            // back to
            // this?
            LoginActivity.return_to = ItemActivity.class.getName();
            LoginActivity.params = new HashMap<String, String>();
            LoginActivity.params.put("item_id", (String) item.item_node.atts.get("id"));
            startActivity(intent);
        } else {
            addToList((String) item.item_node.atts.get("id"));
        }

        break;
    }
    }
    return super.onOptionsItemSelected(menu_item);
}

From source file:com.dmitrymalkovich.android.githubanalytics.navigation.NavigationViewActivity.java

private void signOut() {
    GithubRepository.Injection.provideGithubRepository(this).logout();

    Intent intent = new Intent(this, WelcomeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    startActivity(intent);//from w  w  w.j  av  a  2  s  .c o m
    finish();
}

From source file:com.userhook.UserHook.java

private static void startActivityToRate() {
    Uri uri = Uri.parse("market://details?id=" + applicationContext.getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    if (goToMarket.resolveActivity(applicationContext.getPackageManager()) != null) {
        activityLifecycle.getCurrentActivity().startActivity(goToMarket);
        return;//from   w  w w .jav  a 2 s . c  o  m
    }

    activityLifecycle.getCurrentActivity().startActivity(new Intent(Intent.ACTION_VIEW,
            Uri.parse("http://play.google.com/store/apps/details?id=" + applicationContext.getPackageName())));
}

From source file:com.af.synapse.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mDrawerToggle != null && mDrawerToggle.onOptionsItemSelected(item))
        return true;

    // Handle presses on the action bar items
    switch (item.getItemId()) {
    case R.id.action_apply:
        ActionValueUpdater.applyElements();
        break;/*w ww.  j  ava 2 s  . c  o  m*/
    case R.id.action_cancel:
        ActionValueUpdater.cancelElements();
        break;
    case R.id.action_select_multi:
        startActionMode(ElementSelector.callback);
        break;
    case R.id.action_settings:
        Intent intent = new Intent(this, Settings.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        this.startActivity(intent);
        break;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.paranoid.gerrit.GerritControllerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    Intent intent;//from   ww w. j  a va2 s  .c om
    switch (item.getItemId()) {
    case R.id.menu_save:
        intent = new Intent(this, PrefsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(intent);
        return true;
    case R.id.menu_help:
        showHelpDialog();
        return true;
    case R.id.menu_refresh:
        refreshTabs();
        return true;
    case R.id.menu_team_instance:
        DialogFragment newFragment = new GerritSwitcher();
        String tag = getResources().getString(R.string.choose_gerrit_instance);
        // Must use getFragmentManager not getSupportFragmentManager here
        newFragment.show(getFragmentManager(), tag);
        return true;
    case R.id.menu_projects:
        intent = new Intent(this, ProjectsList.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(intent);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:monakhv.android.samlib.MainActivity.java

@Override
public void addAuthorFromText() {
    EditText editText = (EditText) findViewById(R.id.addUrlText);

    if (editText == null) {
        return;/*from   w ww .  j  a v  a  2  s .  c  o m*/
    }
    if (editText.getText() == null) {
        return;
    }
    String text = editText.getText().toString();
    editText.setText("");

    View v = findViewById(R.id.add_author_panel);
    v.setVisibility(View.GONE);

    String url = SamLibConfig.getParsedUrl(text);
    if (url != null) {
        AddAuthor aa = new AddAuthor(this.getApplicationContext());
        aa.execute(url);
    } else {
        if (TextUtils.isEmpty(text)) {
            return;
        }
        Intent prefsIntent = new Intent(getApplicationContext(), SearchAuthorActivity.class);
        prefsIntent.putExtra(SearchAuthorActivity.EXTRA_PATTERN, text);
        prefsIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

        startActivityForResult(prefsIntent, SEARCH_ACTIVITY);
    }

}

From source file:abanoubm.dayra.main.Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    if (Utility.getArabicLang(getApplicationContext()) == 1) {
        Utility.setArabicLang(getApplicationContext(), 2);

        Locale myLocale = new Locale("ar");
        Resources res = getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();
        conf.locale = myLocale;//from   w ww.jav a2s.co m
        res.updateConfiguration(conf, dm);

        finish();
        startActivity(new Intent(getIntent()));
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_main);
    ((TextView) findViewById(R.id.subhead1)).setText(R.string.app_name);
    ((TextView) findViewById(R.id.subhead2)).setText(BuildConfig.VERSION_NAME);
    findViewById(R.id.nav_back).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();

        }
    });
    ((TextView) findViewById(R.id.footer)).setText("dayra " + BuildConfig.VERSION_NAME + " @"
            + new SimpleDateFormat("yyyy", Locale.getDefault()).format(new Date()) + " Abanoub M.");

    if (!Utility.getDayraName(getApplicationContext()).equals("")) {
        startActivity(new Intent(getApplicationContext(), Home.class));
        finish();
    }

    ListView lv = (ListView) findViewById(R.id.home_list);

    mMenuItemAdapter = new MenuItemAdapter(getApplicationContext(),
            new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.sign_menu))), 1);
    lv.setAdapter(mMenuItemAdapter);

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                sign();
                break;
            case 1:
                register();
                break;
            case 2:
                if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this,
                        Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
                    importDB();
                } else {
                    ActivityCompat.requestPermissions(Main.this,
                            new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }, IMPORT_REQUEST);
                }
                break;
            case 3:
                startActivity(new Intent(Intent.ACTION_VIEW).setData(
                        Uri.parse("https://drive.google.com/file/d/0B1rNCm5K9cvwVXJTTzNqSFdrVk0/view")));
                break;
            case 4:
                startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(
                        "https://drive.google.com/open?id=1flSRdoiIT_hNd96Kxz3Ww3EhXDLZ45FhwFJ2hF9vl7g")));
                break;
            case 5: {

                AlertDialog.Builder builder = new AlertDialog.Builder(Main.this);
                builder.setTitle(R.string.label_choose_language);
                builder.setItems(getResources().getStringArray(R.array.language_menu),
                        new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                String temp;
                                if (which == 1) {
                                    temp = "en";
                                    Utility.setArabicLang(getApplicationContext(), 0);
                                } else {
                                    temp = "ar";
                                    Utility.setArabicLang(getApplicationContext(), 2);
                                }
                                Locale myLocale = new Locale(temp);
                                Resources res = getResources();
                                DisplayMetrics dm = res.getDisplayMetrics();
                                Configuration conf = res.getConfiguration();
                                conf.locale = myLocale;
                                res.updateConfiguration(conf, dm);

                                finish();
                                startActivity(new Intent(getIntent()));
                            }

                        });
                builder.create().show();

            }
                break;
            case 6:
                try {
                    getPackageManager().getPackageInfo("com.facebook.katana", 0);
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/453595434816965"))
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                } catch (Exception e) {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/dayraapp"))
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                }
                break;

            case 7:

                try {
                    getPackageManager().getPackageInfo("com.facebook.katana", 0);
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/1363784786"))
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                } catch (Exception e) {
                    startActivity(
                            new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/EngineeroBono"))
                                    .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                }
                break;
            case 8:
                Uri uri = Uri.parse("market://details?id=" + getPackageName());
                Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                try {
                    startActivity(goToMarket);
                } catch (Exception e) {
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
                }
                break;
            case 9:
                if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this,
                        android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
                    Intent intent = new Intent(Intent.ACTION_VIEW).addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    intent.setDataAndType(Uri.fromFile(new File(Utility.getDayraFolder())), "*/*");
                    startActivity(
                            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                } else {
                    ActivityCompat.requestPermissions(Main.this,
                            new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE },
                            FOLDER_REQUEST);
                }
                break;
            case 10:
                LayoutInflater li = LayoutInflater.from(getApplicationContext());
                final View aboutView = li.inflate(R.layout.dialogue_about, null, false);
                final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create();
                ad.setView(aboutView, 0, 0, 0, 0);
                ad.show();
                ((TextView) aboutView.findViewById(R.id.about))
                        .setText(String.format(getResources().getString(R.string.copyright),
                                Calendar.getInstance().get(Calendar.YEAR)));

                ((TextView) aboutView.findViewById(R.id.notice)).setText(GoogleApiAvailability.getInstance()
                        .getOpenSourceSoftwareLicenseInfo(getApplicationContext()));
                aboutView.findViewById(R.id.btn).setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        ad.cancel();
                    }
                });
                break;
            }
        }
    });

}

From source file:com.hoho.android.usbserial.examples.SerialConsoleActivity.java

/**
 * Starts the activity, using the supplied driver instance.
 *
 * @param context/*  ww  w  .j  ava2  s  .co m*/
 */
static void show(Context context, UsbSerialPort port) {
    sPort = port;
    final Intent intent = new Intent(context, SerialConsoleActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY);
    context.startActivity(intent);
}

From source file:com.stillnojetpacks.huffr.activities.MainActivity.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Intent rateIntentForUrl(String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW, uriForUrl(url));
    int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
    } else {/* w ww  . j a va  2 s  .  com*/
        flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
    }
    intent.addFlags(flags);
    return intent;
}