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:com.sonymobile.dronecontrol.activity.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    switch (id) {
    case R.id.action_settings:
        Intent intent = new Intent(this, AboutActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(intent);/*  w  ww .  j ava  2 s  .  c o  m*/
        break;
    case R.id.action_license:
        loadLicense();
        break;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.abewy.android.apps.openklyph.app.MainActivity.java

private void updateContent(int selection) {
    if (selection != oldSelection) {
        Bundle bundle = new Bundle();
        bundle.putString(KlyphBundleExtras.ELEMENT_ID, KlyphSession.getSessionUserId());

        String className = classes.get(selection);

        if (className.equals("com.abewy.android.apps.openklyph.fragment.Chat")) {
            PackageManager pm = getPackageManager();

            try {
                pm.getPackageInfo(MESSENGER_PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
                Intent intent = getPackageManager().getLaunchIntentForPackage(MESSENGER_PACKAGE_NAME);
                startActivity(intent);/*from  www  . j  a va  2s .c o m*/
            } catch (NameNotFoundException e) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MESSENGER_PLAY_STORE_URI));
                intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                startActivity(intent);
            }
        } else {
            if (selection < navAdapter.getCount())
                setTitle(navAdapter.getItem(selection));
            else
                setTitle(KlyphSession.getSessionUserName());

            Fragment fragment = Fragment.instantiate(MainActivity.this, className, bundle);

            if (previousFragment != null)
                previousFragment.onSetToBack(this);

            FragmentTransaction tx = getFragmentManager().beginTransaction();

            tx.replace(R.id.main, fragment, FRAGMENT_TAG);
            tx.commitAllowingStateLoss();
            ((IKlyphFragment) fragment).onSetToFront(this);

            previousFragment = (IKlyphFragment) fragment;

            navAdapter.setSelectedPosition(selection);
            navAdapter.notifyDataSetChanged();

            oldSelection = selection;

            if (notificationsFragment != null)
                notificationsFragment.setHasOptionsMenu(false);
        }
    }
}

From source file:com.trellmor.berrytubechat.ChatActivity.java

private void initService(BerryTubeBinder service) {
    mBinder = service;//from   w  ww  .  j av  a 2 s.  co  m

    if (mCallback == null) {
        createCallback();
    }
    mBinder.getService().setCallback(mCallback);

    mBinder.getService().setChatMsgBufferSize(mScrollback);

    mBinder.getService().setNotification(mNotification);
    mNotification = null;

    if (mChatAdapter == null) {
        mChatAdapter = new ChatMessageAdapter(ChatActivity.this, R.layout.chat_item,
                mBinder.getService().getChatMsgBuffer());
        mListChat.setAdapter(mChatAdapter);
    }

    mChatAdapter.notifyDataSetChanged();
    setNick(mBinder.getService().getNick());
    mDrinkCount = mBinder.getService().getDrinkCount();
    updateDrinkCount();

    if (!mBinder.getService().isConnected()) {
        try {
            // Only connect if we got Username and Password from
            // MainActivity, otherwise wait until BerryTube reconnect
            // normally
            if (mUsername != null && mPassword != null) {
                NotificationCompat.Builder note = new NotificationCompat.Builder(this);
                note.setSmallIcon(R.drawable.ic_stat_notify_berrytube);
                note.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
                note.setContentTitle(getString(R.string.title_activity_chat));

                Intent intent = new Intent(this, ChatActivity.class);
                intent.setAction(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_LAUNCHER);
                intent.putExtra(MainActivity.KEY_USERNAME, mUsername);
                intent.putExtra(MainActivity.KEY_PASSWORD, mPassword);
                intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP
                        | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY);

                note.setContentIntent(
                        PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
                mBinder.getService().connect(mUsername, mPassword, note);
            }
        } catch (MalformedURLException e) {
            Log.w(TAG, e);
        } catch (IllegalStateException e) {
            // already connected, ignore
        }
    }
}

From source file:com.android.messaging.ui.UIIntentsImpl.java

@Override
public Intent getLaunchConversationActivityIntent(final Context context) {
    final Intent intent = new Intent(context, LaunchConversationActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY);
    return intent;
}

From source file:com.tenforwardconsulting.cordova.BackgroundGeolocationPlugin.java

public void showAppSettings() {
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse("package:" + getContext().getPackageName()));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    getContext().startActivity(intent);//from ww w. j av a  2s. c  om
}

From source file:de.baumann.browser.helper.helper_main.java

private static void openFile(Activity activity, File file, String string, View view) {

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        Uri contentUri = FileProvider.getUriForFile(activity,
                activity.getApplicationContext().getPackageName() + ".provider", file);
        intent.setDataAndType(contentUri, string);

    } else {/* w  w w .  jav  a 2s  . co m*/
        intent.setDataAndType(Uri.fromFile(file), string);
    }

    try {
        activity.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Snackbar.make(view, R.string.toast_install_app, Snackbar.LENGTH_LONG).show();
    }
}

From source file:com.abewy.android.apps.klyph.app.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    /*//w  ww  .  j  a  v a  2 s .c om
     * if (drawerToggle.onOptionsItemSelected(item))
     * {
     * return true;
     * }
     */

    if (item.getItemId() == android.R.id.home) {
        if (drawer.isDrawerOpen(Gravity.LEFT)) {
            drawer.closeDrawer(Gravity.LEFT);

            if (drawer.isDrawerOpen(Gravity.RIGHT))
                drawer.closeDrawer(Gravity.RIGHT);
        } else {
            drawer.openDrawer(Gravity.LEFT);

            if (drawer.isDrawerOpen(Gravity.RIGHT))
                drawer.closeDrawer(Gravity.RIGHT);
        }

        return true;
    } else if (item.getItemId() == R.id.menu_notifications) {
        if (drawer.isDrawerOpen(Gravity.RIGHT)) {
            drawer.closeDrawer(Gravity.RIGHT);

            if (drawer.isDrawerOpen(Gravity.LEFT))
                drawer.closeDrawer(Gravity.LEFT);
        } else {
            drawer.openDrawer(Gravity.RIGHT);

            if (drawer.isDrawerOpen(Gravity.LEFT))
                drawer.closeDrawer(Gravity.LEFT);
        }

        return true;
    } else if (item.getItemId() == R.id.menu_buy_pro) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(KLYPH_PRO_PLAY_STORE_URI));
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        startActivity(intent);
    } else if (item.getItemId() == R.id.menu_logout) {
        AlertUtil.showAlert(this, R.string.menu_logout, R.string.logout_confirmation, R.string.ok,
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        logout();
                    }
                }, R.string.cancel, null);

        return true;
    } else if (item.getItemId() == R.id.menu_faq) {
        startActivity(new Intent(this, FaqActivity.class));
    }

    return super.onOptionsItemSelected(item);
}

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

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {

    boolean super_answer = super.onContextItemSelected(item);
    Log.d(DEBUG_TAG, "context menu item selected: " + item.getItemId() + "  super: " + super_answer);

    if (author != null) {
        if (item.getItemId() == delete_option_item) {
            Dialog alert = createDeleteAuthorAlert(author.getName());
            alert.show();//from www. j av  a2s .  com
        }

        if (item.getItemId() == read_option_item) {
            MarkRead marker = new MarkRead(getActivity().getApplicationContext());
            marker.execute(author.getId());
        }
        if (item.getItemId() == tags_option_item) {
            Intent intent = new Intent(getActivity(), AuthorTagsActivity.class);
            intent.putExtra(AuthorTagsActivity.AUTHOR_ID, author.getId());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            startActivity(intent);

        }
        if (item.getItemId() == browser_option_item) {
            launchBrowser(author);
        }
        if (item.getItemId() == update_option_item) {
            updateAuthor = true;
            startRefresh();
        }
        if (item.getItemId() == edit_author_option_item) {
            EnterStringDialog ddialog = new EnterStringDialog(getActivity(),
                    new EnterStringDialog.ClickListener() {
                        public void okClick(String txt) {
                            author.setName(txt);
                            sql.update(author);
                        }
                    }, getText(R.string.dialog_title_edit_author).toString(), author.getName());

            ddialog.show();
        }

    } else {
        Log.e(DEBUG_TAG, "Author Object is NULL!!");
    }

    return super.onContextItemSelected(item);

}

From source file:com.android.messaging.ui.UIIntentsImpl.java

@Override
public PendingIntent getWidgetPendingIntentForConfigurationActivity(final Context context,
        final int appWidgetId) {
    final Intent configureIntent = new Intent(context, WidgetPickConversationActivity.class);
    configureIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    configureIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
    configureIntent.setData(Uri.parse(configureIntent.toUri(Intent.URI_INTENT_SCHEME)));
    configureIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
    return getPendingIntentWithParentStack(context, configureIntent, 0);
}

From source file:mgks.os.webview.MainActivity.java

public void show_notification(int type, int id) {
    long when = System.currentTimeMillis();
    asw_notification = (NotificationManager) MainActivity.this.getSystemService(Context.NOTIFICATION_SERVICE);
    Intent i = new Intent();
    if (type == 1) {
        i.setClass(MainActivity.this, MainActivity.class);
    } else if (type == 2) {
        i.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    } else {/*from  w w  w . ja v  a2  s. c o  m*/
        i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        i.addCategory(Intent.CATEGORY_DEFAULT);
        i.setData(Uri.parse("package:" + MainActivity.this.getPackageName()));
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    }
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 0, i,
            PendingIntent.FLAG_UPDATE_CURRENT);

    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this, "");
    switch (type) {
    case 1:
        builder.setTicker(getString(R.string.app_name));
        builder.setContentTitle(getString(R.string.loc_fail));
        builder.setContentText(getString(R.string.loc_fail_text));
        builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getString(R.string.loc_fail_more)));
        builder.setVibrate(new long[] { 350, 350, 350, 350, 350 });
        builder.setSmallIcon(R.mipmap.ic_launcher);
        break;

    case 2:
        builder.setTicker(getString(R.string.app_name));
        builder.setContentTitle(getString(R.string.loc_perm));
        builder.setContentText(getString(R.string.loc_perm_text));
        builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getString(R.string.loc_perm_more)));
        builder.setVibrate(new long[] { 350, 700, 350, 700, 350 });
        builder.setSound(alarmSound);
        builder.setSmallIcon(R.mipmap.ic_launcher);
        break;
    }
    builder.setOngoing(false);
    builder.setAutoCancel(true);
    builder.setContentIntent(pendingIntent);
    builder.setWhen(when);
    builder.setContentIntent(pendingIntent);
    asw_notification_new = builder.build();
    asw_notification.notify(id, asw_notification_new);
}