Example usage for android.content Intent FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY

List of usage examples for android.content Intent FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY

Introduction

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

Prototype

int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY

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

Click Source Link

Document

This flag is not normally set by application code, but set for you by the system if this activity is being launched from history (longpress home key).

Usage

From source file:Main.java

public static void openActivityFromHistory(Activity activity, Class<?> pClass) {
    Intent intent = new Intent(activity, pClass);
    intent.setFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
    activity.startActivity(intent);/*from  w  w w  .  jav a2 s .c om*/
}

From source file:org.mozilla.focus.activity.MainActivity.java

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

    if (Settings.getInstance(this).shouldUseSecureMode()) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
    }/*from   w w w . j  av  a2s  .c om*/

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

    setContentView(R.layout.activity_main);

    SafeIntent intent = new SafeIntent(getIntent());

    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0
            && !BrowsingSession.getInstance().isActive()) {
        // This Intent was launched from history (recent apps). Android will redeliver the
        // original Intent (which might be a VIEW intent). However if there's no active browsing
        // session then we do not want to re-process the Intent and potentially re-open a website
        // from a session that the user already "erased".
        intent = new SafeIntent(new Intent(Intent.ACTION_MAIN));
        setIntent(intent.getUnsafe());
    }

    if (savedInstanceState == null) {
        WebViewProvider.performCleanup(this);

        if (Intent.ACTION_VIEW.equals(intent.getAction())) {
            final String url = intent.getDataString();

            BrowsingSession.getInstance().loadCustomTabConfig(intent);

            if (Settings.getInstance(this).shouldShowFirstrun()) {
                pendingUrl = url;
                showFirstrun();
            } else {
                showBrowserScreen(url);
            }
        } else {
            if (Settings.getInstance(this).shouldShowFirstrun()) {
                showFirstrun();
            } else {
                showHomeScreen();
            }
        }
    }

    WebViewProvider.preload(this);
}

From source file:com.probam.updater.ui.fragment.UpdateFragment.java

public void checkIntent(Intent intent) {
    if (intent != null) {
        mIntent = intent;// w w w . j  a  v  a2s  . c  o m
    }
    if (mIntent != null && mIntent.getExtras() != null
            && mIntent.getExtras().get(Constants.FILE_INFO) != null) {
        if ((mIntent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
            PackageInfo info = ManagerFactory.getFileManager(getActivity()).onNewIntent(getActivity(), mIntent);
            if (!(info instanceof CancelPackage)) {
                mNewRom = info;
                if (mNewRom != null && mNewRom.isGapps()) {
                    if (mGappsUpdater == null) {
                        mGappsUpdater = new GappsUpdater(getActivity(), this, false);
                    }
                    mGappsUpdater.versionFound(mNewRom);
                }
            }
        }
    }

    if (mNewRom != null || !mStartup) {
        if (mNewRom != null && !mNewRom.isGapps()) {
            checkRomCompleted(mNewRom);
        } else if (mRomCanUpdate) {
            if (mStartup) {
                checkRom();
            } else {
                checkRomCompleted(mNewRom);
            }
        }
    } else if (mRomCanUpdate) {
        checkRom();
    }
}

From source file:com.example.mobilewebproxy.MainActivity.java

private void createNotification() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher).setContentTitle("Mobile web proxy")
            .setContentText("Proxy server started");

    Intent resultIntent = new Intent(this, MainActivity.class);
    resultIntent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);

    PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent, 0);

    builder.setContentIntent(resultPendingIntent);

    _notificationManager.notify(2, builder.getNotification());
}

From source file:ren.qinc.markdowneditors.view.EditorActivity.java

private void getIntentData() {
    Intent intent = this.getIntent();
    int flags = intent.getFlags();
    if ((flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
        if (intent.getAction() != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
            if (SCHEME_FILE.equals(intent.getScheme())) {
                //
                String type = getIntent().getType();
                // mImportingUri=file:///storage/emulated/0/Vlog.xml
                intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                Uri uri = intent.getData();

                if (uri != null && SCHEME_FILE.equalsIgnoreCase(uri.getScheme())) {
                    //
                    currentFilePath = FileUtils.uri2FilePath(getBaseContext(), uri);
                }/*from  ww w  .j ava2 s  .c o m*/
            }
        }
    }
}

From source file:com.zhongzilu.bit100.view.activity.EditorActivity.java

private void getIntentData() {
    Intent intent = this.getIntent();
    int flags = intent.getFlags();
    if ((flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
        if (intent.getAction() != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
            if (SCHEME_FILE.equals(intent.getScheme())) {
                //
                //                    String type = getIntent().getType();
                // mImportingUri=file:///storage/emulated/0/Vlog.xml
                intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                Uri uri = intent.getData();

                if (uri != null && SCHEME_FILE.equalsIgnoreCase(uri.getScheme())) {
                    //
                    currentFilePath = FileUtils.uri2FilePath(getBaseContext(), uri);
                }/*from   w  w  w .j  a va 2s  . c om*/
            }
        }
    }
}

From source file:com.meiste.greg.ptw.GameActivity.java

private int getTab(final Intent intent) {
    // Recent applications caches intent with extras. Only want to listen
    // to INTENT_TAB extra if launched from notification.
    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
        final int intent_tab = intent.getIntExtra(PTW.INTENT_EXTRA_TAB, -1);
        if (intent_tab >= 0) {
            return intent_tab;
        }//  ww  w  . j av  a  2s  . co m
    }

    return Util.getState(this).getInt(LAST_TAB, 0);
}

From source file:com.yahala.ui.LaunchActivity.java

private void handleIntent(Intent intent, boolean isNew, boolean restore) {
    boolean pushOpened = false;

    String push_user_jid = "0";
    Integer push_chat_id = 0;// w  w  w. j  a v a 2  s. c  o  m
    Integer push_enc_id = 0;
    Integer open_settings = 0;

    photoPath = null;
    videoPath = null;
    sendingText = null;
    documentPath = null;
    imagesPathArray = null;
    documentsPathArray = null;
    // FileLog.e("intent.getAction()", intent.getAction().toString());
    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
        if (intent.getAction() != null && intent.getAction().startsWith("com.yahala.openchat") && !restore) {
            int chatId = intent.getIntExtra("chatId", 0);
            String userId = intent.getStringExtra("user_jid");
            int encId = intent.getIntExtra("encId", 0);
            if (chatId != 0) {
                TLRPC.Chat chat = MessagesController.getInstance().chats.get(chatId);
                if (chat != null) {
                    NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
                    push_chat_id = chatId;
                }
            } else if (userId != null || userId != "") {
                TLRPC.User user = ContactsController.getInstance().friendsDict.get(userId);
                if (user != null) {
                    FileLog.d("closeChats", "" + userId);
                    NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
                    push_user_jid = userId;
                }
            }
        }
    }

    if (push_user_jid != "0") {
        if (push_user_jid == UserConfig.currentUser.phone) {
            open_settings = 1;
        } else {
            Bundle args = new Bundle();
            args.putString("user_jid", push_user_jid);
            ChatActivity fragment = new ChatActivity();
            fragment.setArguments(args);
            if (fragment.onFragmentCreate()) {
                pushOpened = true;
                ApplicationLoader.fragmentsStack.add(fragment);
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss();
            }
        }
    } else if (push_chat_id != 0) {
        Bundle args = new Bundle();
        args.putInt("chat_id", push_chat_id);
        ChatActivity fragment = new ChatActivity();
        fragment.setArguments(args);
        ApplicationLoader.fragmentsStack.add(fragment);
        fragment.onFragmentCreate();
        pushOpened = true;
    } else if (push_enc_id != 0) {
        Bundle args = new Bundle();
        args.putInt("enc_id", push_enc_id);

        ChatActivity fragment = new ChatActivity();
        fragment.setArguments(args);
        ApplicationLoader.fragmentsStack.add(fragment);
        fragment.onFragmentCreate();
        pushOpened = true;

    }
    /* if (videoPath != null || photoPathsArray != null || sendingText != null || documentsPathsArray != null || contactsToSend != null) {
    NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
    Bundle args = new Bundle();
    args.putBoolean("onlySelect", true);
    args.putString("selectAlertString", LocaleController.getString("ForwardMessagesTo", R.string.ForwardMessagesTo));
    MessagesActivity fragment = new MessagesActivity(args);
    fragment.setDelegate(this);
    presentFragment(fragment, false, true);
    pushOpened = true;
    } */

    if (open_settings != 0) {
        ApplicationLoader.fragmentsStack.clear();
        SettingsActivity fragment = new SettingsActivity();
        ApplicationLoader.fragmentsStack.add(fragment);
        getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "settings")
                .commitAllowingStateLoss();
        pushOpened = true;
    }
    if (!pushOpened && !isNew) {
        BaseFragment fragment = ApplicationLoader.fragmentsStack
                .get(ApplicationLoader.fragmentsStack.size() - 1);
        getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, fragment.getTag())
                .commitAllowingStateLoss();
    }

    intent.setAction(null);
}

From source file:org.geometerplus.android.fbreader.FBReader.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler(this));

    bindService(new Intent(this, DataService.class), DataConnection, DataService.BIND_AUTO_CREATE);

    final Config config = Config.Instance();
    config.runOnConnect(new Runnable() {
        public void run() {
            config.requestAllValuesForGroup("Options");
            config.requestAllValuesForGroup("Style");
            config.requestAllValuesForGroup("LookNFeel");
            config.requestAllValuesForGroup("Fonts");
            config.requestAllValuesForGroup("Colors");
            config.requestAllValuesForGroup("Files");
        }/*w ww .  ja  v a  2s. c  om*/
    });

    final ZLAndroidLibrary zlibrary = getZLibrary();
    myShowStatusBarFlag = zlibrary.ShowStatusBarOption.getValue();

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);
    myRootView = (RelativeLayout) findViewById(R.id.root_view);
    myMainView = (ZLAndroidWidget) findViewById(R.id.main_view);
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    zlibrary.setActivity(this);

    myFBReaderApp = (FBReaderApp) FBReaderApp.Instance();
    if (myFBReaderApp == null) {
        myFBReaderApp = new FBReaderApp(new BookCollectionShadow());
    }
    getCollection().bindToService(this, null);
    myBook = null;

    myFBReaderApp.setWindow(this);
    myFBReaderApp.initWindow();

    myFBReaderApp.setExternalFileOpener(new ExternalFileOpener(this));

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            myShowStatusBarFlag ? 0 : WindowManager.LayoutParams.FLAG_FULLSCREEN);

    if (myFBReaderApp.getPopupById(TextSearchPopup.ID) == null) {
        new TextSearchPopup(myFBReaderApp);
    }
    if (myFBReaderApp.getPopupById(NavigationPopup.ID) == null) {
        new NavigationPopup(myFBReaderApp);
    }
    if (myFBReaderApp.getPopupById(SelectionPopup.ID) == null) {
        new SelectionPopup(myFBReaderApp);
    }

    myFBReaderApp.addAction(ActionCode.SHOW_LIBRARY, new ShowLibraryAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SHOW_PREFERENCES, new ShowPreferencesAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SHOW_BOOK_INFO, new ShowBookInfoAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SHOW_TOC, new ShowTOCAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SHOW_BOOKMARKS, new ShowBookmarksAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SHOW_NETWORK_LIBRARY, new ShowNetworkLibraryAction(this, myFBReaderApp));

    myFBReaderApp.addAction(ActionCode.SHOW_MENU, new ShowMenuAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SHOW_NAVIGATION, new ShowNavigationAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SEARCH, new SearchAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SHARE_BOOK, new ShareBookAction(this, myFBReaderApp));

    myFBReaderApp.addAction(ActionCode.SELECTION_SHOW_PANEL, new SelectionShowPanelAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SELECTION_HIDE_PANEL, new SelectionHidePanelAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SELECTION_COPY_TO_CLIPBOARD,
            new SelectionCopyAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SELECTION_SHARE, new SelectionShareAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SELECTION_TRANSLATE, new SelectionTranslateAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.SELECTION_BOOKMARK, new SelectionBookmarkAction(this, myFBReaderApp));

    myFBReaderApp.addAction(ActionCode.PROCESS_HYPERLINK, new ProcessHyperlinkAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.OPEN_VIDEO, new OpenVideoAction(this, myFBReaderApp));

    myFBReaderApp.addAction(ActionCode.SHOW_CANCEL_MENU, new ShowCancelMenuAction(this, myFBReaderApp));

    myFBReaderApp.addAction(ActionCode.SET_SCREEN_ORIENTATION_SYSTEM,
            new SetScreenOrientationAction(this, myFBReaderApp, ZLibrary.SCREEN_ORIENTATION_SYSTEM));
    myFBReaderApp.addAction(ActionCode.SET_SCREEN_ORIENTATION_SENSOR,
            new SetScreenOrientationAction(this, myFBReaderApp, ZLibrary.SCREEN_ORIENTATION_SENSOR));
    myFBReaderApp.addAction(ActionCode.SET_SCREEN_ORIENTATION_PORTRAIT,
            new SetScreenOrientationAction(this, myFBReaderApp, ZLibrary.SCREEN_ORIENTATION_PORTRAIT));
    myFBReaderApp.addAction(ActionCode.SET_SCREEN_ORIENTATION_LANDSCAPE,
            new SetScreenOrientationAction(this, myFBReaderApp, ZLibrary.SCREEN_ORIENTATION_LANDSCAPE));
    if (ZLibrary.Instance().supportsAllOrientations()) {
        myFBReaderApp.addAction(ActionCode.SET_SCREEN_ORIENTATION_REVERSE_PORTRAIT,
                new SetScreenOrientationAction(this, myFBReaderApp,
                        ZLibrary.SCREEN_ORIENTATION_REVERSE_PORTRAIT));
        myFBReaderApp.addAction(ActionCode.SET_SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
                new SetScreenOrientationAction(this, myFBReaderApp,
                        ZLibrary.SCREEN_ORIENTATION_REVERSE_LANDSCAPE));
    }
    myFBReaderApp.addAction(ActionCode.OPEN_WEB_HELP, new OpenWebHelpAction(this, myFBReaderApp));
    myFBReaderApp.addAction(ActionCode.INSTALL_PLUGINS, new InstallPluginsAction(this, myFBReaderApp));

    final Intent intent = getIntent();
    final String action = intent.getAction();

    myOpenBookIntent = intent;
    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
        if (FBReaderIntents.Action.CLOSE.equals(action)) {
            myCancelIntent = intent;
            myOpenBookIntent = null;
        } else if (FBReaderIntents.Action.PLUGIN_CRASH.equals(action)) {
            myFBReaderApp.ExternalBook = null;
            myOpenBookIntent = null;
            getCollection().bindToService(this, new Runnable() {
                public void run() {
                    myFBReaderApp.openBook(null, null, null, FBReader.this);
                }
            });
        }
    }
}

From source file:org.geometerplus.android.fbreader.FBReader.java

@Override
protected void onNewIntent(final Intent intent) {
    final String action = intent.getAction();
    final Uri data = intent.getData();

    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        super.onNewIntent(intent);
    } else if (Intent.ACTION_VIEW.equals(action) && data != null
            && "fbreader-action".equals(data.getScheme())) {
        myFBReaderApp.runAction(data.getEncodedSchemeSpecificPart(), data.getFragment());
    } else if (Intent.ACTION_VIEW.equals(action) || FBReaderIntents.Action.VIEW.equals(action)) {
        myOpenBookIntent = intent;//  w  w  w.ja v  a2s  .  com
        if (myFBReaderApp.Model == null && myFBReaderApp.ExternalBook != null) {
            final ExternalFormatPlugin plugin = (ExternalFormatPlugin) myFBReaderApp.ExternalBook
                    .getPluginOrNull();
            try {
                startActivity(PluginUtil.createIntent(plugin, PluginUtil.ACTION_KILL));
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
            }
        }
    } else if (FBReaderIntents.Action.PLUGIN.equals(action)) {
        new RunPluginAction(this, myFBReaderApp, data).run();
    } else if (Intent.ACTION_SEARCH.equals(action)) {
        final String pattern = intent.getStringExtra(SearchManager.QUERY);
        final Runnable runnable = new Runnable() {
            public void run() {
                final TextSearchPopup popup = (TextSearchPopup) myFBReaderApp.getPopupById(TextSearchPopup.ID);
                popup.initPosition();
                myFBReaderApp.MiscOptions.TextSearchPattern.setValue(pattern);
                if (myFBReaderApp.getTextView().search(pattern, true, false, false, false) != 0) {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            myFBReaderApp.showPopup(popup.getId());
                        }
                    });
                } else {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            UIUtil.showErrorMessage(FBReader.this, "textNotFound");
                            popup.StartPosition = null;
                        }
                    });
                }
            }
        };
        UIUtil.wait("search", runnable, this);
    } else if (FBReaderIntents.Action.CLOSE.equals(intent.getAction())) {
        myCancelIntent = intent;
        myOpenBookIntent = null;
    } else if (FBReaderIntents.Action.PLUGIN_CRASH.equals(intent.getAction())) {
        final Book book = FBReaderIntents.getBookExtra(intent);
        myFBReaderApp.ExternalBook = null;
        myOpenBookIntent = null;
        getCollection().bindToService(this, new Runnable() {
            public void run() {
                Book b = myFBReaderApp.Collection.getRecentBook(0);
                if (b.equals(book)) {
                    b = myFBReaderApp.Collection.getRecentBook(1);
                }
                myFBReaderApp.openBook(b, null, null, FBReader.this);
            }
        });
    } else {
        super.onNewIntent(intent);
    }
}