Java Code Examples for android.content.Intent#FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY

The following examples show how to use android.content.Intent#FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void resolveIntent(Intent data) {
    this.setIntent(data);

    if ((data.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        return;
    }

    if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(data.getAction())) {
        mLastNfcTag = data.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        long now = new Date().getTime();

        if (mContinuousSensorReadingFlag) {
            startContinuousSensorReadingTimer();

        } else if (now - mLastScanTime > 5000) {
            DataPlotFragment dataPlotFragment = (DataPlotFragment)
                    mSectionsPagerAdapter.getRegisteredFragment(R.integer.viewpager_page_show_scan);
            if (dataPlotFragment != null) {
                dataPlotFragment.clearScanData();
            }

            new NfcVReaderTask(this).execute(mLastNfcTag);
        }
    }
}
 
Example 2
Source Project: SendBird-Android   File: SplashActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    if (getIntent() != null && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) {
        getIntent().removeExtra(MainActivity.EXTRA_GROUP_CHANNEL_URL);
    }

    if (ConnectionManager.isLogin() && PreferenceUtils.getUserId() != null) {
        setUpSyncManager();
    } else {
        startActivity(new Intent(SplashActivity.this, LoginActivity.class));
        finish();
    }
}
 
Example 3
Source Project: delion   File: ChromeTabbedActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void preInflationStartup() {
    super.preInflationStartup();

    // Decide whether to record startup UMA histograms. This is done  early in the main
    // Activity.onCreate() to avoid recording navigation delays when they require user input to
    // proceed. For example, FRE (First Run Experience) happens before the activity is created,
    // and triggers initialization of the native library. At the moment it seems safe to assume
    // that uninitialized native library is an indication of an application start that is
    // followed by navigation immediately without user input.
    if (!LibraryLoader.isInitialized()) {
        UmaUtils.setRunningApplicationStart(true);
    }

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS)
            && getIntent() != null
            && getIntent().hasExtra(
                    ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT)) {
        int value = getIntent().getIntExtra(
                ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT, -1);
        if (value != -1) {
            String[] args = new String[1];
            args[0] = "--" + ContentSwitches.RENDER_PROCESS_LIMIT
                    + "=" + Integer.toString(value);
            commandLine.appendSwitchesAndArguments(args);
        }
    }

    supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);

    // We are starting from history with a URL after data has been cleared. On Samsung this
    // can happen after user clears data and clicks on a recents item on pre-L devices.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
            && getIntent().getData() != null
            && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0
            && OmahaClient.isFreshInstallOrDataHasBeenCleared(getApplicationContext())) {
        getIntent().setData(null);
    }
}
 
Example 4
Source Project: xDrip   File: NFCFilterX.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    final Intent intent = getIntent();
    this.setIntent(intent);

    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        return;
    }
    NFCReaderX.scanFromActivity(this, intent);

}
 
Example 5
Source Project: xDrip   File: NFCFilterX.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    final Intent intent = getIntent();
    this.setIntent(intent);

    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        return;
    }
    NFCReaderX.scanFromActivity(this, intent);

}
 
Example 6
@Override
protected void onResume() {
    super.onResume();

    final Intent intent = getIntent();
    this.setIntent(intent);

    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        return;
    }
    NFCReaderX.scanFromActivity(this, intent);

}
 
Example 7
@Override
protected void onResume() {
    super.onResume();

    final Intent intent = getIntent();
    this.setIntent(intent);

    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        return;
    }
    NFCReaderX.scanFromActivity(this, intent);

}
 
Example 8
@Override
protected void onResume() {
    super.onResume();

    final Intent intent = getIntent();
    this.setIntent(intent);

    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        return;
    }
}
 
Example 9
@Override
public void preInflationStartup() {
    super.preInflationStartup();

    // Decide whether to record startup UMA histograms. This is done  early in the main
    // Activity.onCreate() to avoid recording navigation delays when they require user input to
    // proceed. For example, FRE (First Run Experience) happens before the activity is created,
    // and triggers initialization of the native library. At the moment it seems safe to assume
    // that uninitialized native library is an indication of an application start that is
    // followed by navigation immediately without user input.
    if (!LibraryLoader.isInitialized()) {
        UmaUtils.setRunningApplicationStart(true);
    }

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS)
            && getIntent() != null
            && getIntent().hasExtra(
                    ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT)) {
        int value = getIntent().getIntExtra(
                ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT, -1);
        if (value != -1) {
            String[] args = new String[1];
            args[0] = "--" + ContentSwitches.RENDER_PROCESS_LIMIT
                    + "=" + Integer.toString(value);
            commandLine.appendSwitchesAndArguments(args);
        }
    }

    supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);

    // We are starting from history with a URL after data has been cleared. On Samsung this
    // can happen after user clears data and clicks on a recents item on pre-L devices.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
            && getIntent().getData() != null
            && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0
            && OmahaClient.isFreshInstallOrDataHasBeenCleared(getApplicationContext())) {
        getIntent().setData(null);
    }
}
 
Example 10
private void handleExternalPlayOnChromecast(final Intent intent) {
	if(intent != null) {
		// If we're connected to a chromecast when we receive this video to play, play it there, otherwise
		// forward it on to the local player. HOWEVER, we need to skip this if the calling Intent's class name
		// is YouTubePlayerActivity, otherwise we'll get stuck in an endless loop!
		if(intent.getAction() != null &&
						intent.getAction().equals(Intent.ACTION_VIEW) &&
						!intent.getComponent().getClassName().equals(YouTubePlayerActivity.class.getName()) &&
						(intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {


			/**
			 * If a default Chromecast has been set for videos received via an external app (AutoCast), show the
			 * loading spinner and save the intent (which contains the video to play). When the Chromecast (route) is
			 * discovered above, it will find the default Chromecast and connect to it. Once the connection is
			 * established, {@link #handleExternalPlayOnChromecast(Intent)} will be called again, this time with
			 * externalPlayIntent set, which will allow the video to be launched on the Chromecast. Also only do
			 * this if we aren't already connected to a Chromecast.
			 */
			final boolean connectedToChromecast = YouTubePlayer.isConnectedToChromecast();
			if(launchExternalOnDefaultChromecast(this) && externalPlayIntent == null && !connectedToChromecast) {
				showLoadingSpinner();
				externalPlayIntent = intent;
			} else {
				if (connectedToChromecast) {
					new GetVideoDetailsTask(this, intent, (videoId, video) -> playVideoOnChromecast(video, 0)).executeInParallel();
				} else {
					Intent i = new Intent(this, YouTubePlayerActivity.class);
					i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
					i.setAction(Intent.ACTION_VIEW);
					i.setData(intent.getData());
					startActivity(i);
					finish(); // Finish this activity, so that the back button returns to the app that launched this video
				}
			}
		}
	}
}
 
Example 11
private void handleIntent(Intent intent)
{
  if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0)
    return;

  final MWMResponse mwmResponse = MWMResponse.extractFromIntent(this, intent);
  final MWMPoint point = mwmResponse.getPoint();

  if (point != null && point.getId() != null)
  {
    final String id = point.getId();
    Log.d(TAG, id);
    onItemSelected(Storage.get(this).getArticleInfoByUrl(id));
  }
}
 
Example 12
@Override
public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    // If it is not launched from history, then reset to top-level
    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
        if (mFirstHeader != null && !onIsHidingHeaders() && onIsMultiPane()) {
            switchToHeaderLocal(mFirstHeader);
        }
        getListView().setSelectionFromTop(0, 0);
    }
}
 
Example 13
Source Project: coursera-android   File: DialtactsActivity.java    License: MIT License 5 votes vote down vote up
/**
 * Stores the filter text associated with a FILTER_CONTACTS_ACTION intent.
 * This is so child activities can check if they are supposed to display a filter.
 *
 * @param intent The intent received in {@link #onNewIntent(Intent)}
 */
private void setupFilterText(Intent intent) {
    // If the intent was relaunched from history, don't apply the filter text.
    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        return;
    }
    String filter = intent.getStringExtra(UI.FILTER_TEXT_EXTRA_KEY);
    if (filter != null && filter.length() > 0) {
        mFilterText = filter;
    }
}
 
Example 14
public static boolean handleProxyIntent(Activity activity, Intent intent)
{
    if (intent == null)
    {
        return false;
    }
    try
    {
        if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0)
        {
            return false;
        }
        Uri data = intent.getData();
        if (data != null)
        {
            String user = null;
            String password = null;
            String port = null;
            String address = null;
            String secret = null;
            String scheme = data.getScheme();
            if (scheme != null)
            {
                if ((scheme.equals("http") || scheme.equals("https")))
                {
                    String host = data.getHost().toLowerCase();
                    if (host.equals("telegram.me") || host.equals("t.me") || host.equals("telegram.dog") || host.equals("telesco.pe"))
                    {
                        String path = data.getPath();
                        if (path != null)
                        {
                            if (path.startsWith("/socks") || path.startsWith("/proxy"))
                            {
                                address = data.getQueryParameter("server");
                                port = data.getQueryParameter("port");
                                user = data.getQueryParameter("user");
                                password = data.getQueryParameter("pass");
                                secret = data.getQueryParameter("secret");
                            }
                        }
                    }
                }
                else if (scheme.equals("tg"))
                {
                    String url = data.toString();
                    if (url.startsWith("tg:proxy") || url.startsWith("tg://proxy") || url.startsWith("tg:socks") || url.startsWith("tg://socks"))
                    {
                        url = url.replace("tg:proxy", "tg://telegram.org").replace("tg://proxy", "tg://telegram.org").replace("tg://socks", "tg://telegram.org").replace("tg:socks", "tg://telegram.org");
                        data = Uri.parse(url);
                        address = data.getQueryParameter("server");
                        port = data.getQueryParameter("port");
                        user = data.getQueryParameter("user");
                        password = data.getQueryParameter("pass");
                        secret = data.getQueryParameter("secret");
                    }
                }
            }
            if (!TextUtils.isEmpty(address) && !TextUtils.isEmpty(port))
            {
                if (user == null)
                {
                    user = "";
                }
                if (password == null)
                {
                    password = "";
                }
                if (secret == null)
                {
                    secret = "";
                }
                showProxyAlert(activity, address, port, user, password, secret);
                return true;
            }
        }
    }
    catch (Exception ignore) {}
    return false;
}
 
Example 15
public static boolean handleProxyIntent(Activity activity, Intent intent)
{
    if (intent == null)
    {
        return false;
    }
    try
    {
        if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0)
        {
            return false;
        }
        Uri data = intent.getData();
        if (data != null)
        {
            String user = null;
            String password = null;
            String port = null;
            String address = null;
            String secret = null;
            String scheme = data.getScheme();
            if (scheme != null)
            {
                if ((scheme.equals("http") || scheme.equals("https")))
                {
                    String host = data.getHost().toLowerCase();
                    if (host.equals("telegram.me") || host.equals("t.me") || host.equals("telegram.dog") || host.equals("telesco.pe"))
                    {
                        String path = data.getPath();
                        if (path != null)
                        {
                            if (path.startsWith("/socks") || path.startsWith("/proxy"))
                            {
                                address = data.getQueryParameter("server");
                                port = data.getQueryParameter("port");
                                user = data.getQueryParameter("user");
                                password = data.getQueryParameter("pass");
                                secret = data.getQueryParameter("secret");
                            }
                        }
                    }
                }
                else if (scheme.equals("tg"))
                {
                    String url = data.toString();
                    if (url.startsWith("tg:proxy") || url.startsWith("tg://proxy") || url.startsWith("tg:socks") || url.startsWith("tg://socks"))
                    {
                        url = url.replace("tg:proxy", "tg://telegram.org").replace("tg://proxy", "tg://telegram.org").replace("tg://socks", "tg://telegram.org").replace("tg:socks", "tg://telegram.org");
                        data = Uri.parse(url);
                        address = data.getQueryParameter("server");
                        port = data.getQueryParameter("port");
                        user = data.getQueryParameter("user");
                        password = data.getQueryParameter("pass");
                        secret = data.getQueryParameter("secret");
                    }
                }
            }
            if (!TextUtils.isEmpty(address) && !TextUtils.isEmpty(port))
            {
                if (user == null)
                {
                    user = "";
                }
                if (password == null)
                {
                    password = "";
                }
                if (secret == null)
                {
                    secret = "";
                }
                showProxyAlert(activity, address, port, user, password, secret);
                return true;
            }
        }
    }
    catch (Exception ignore) {}
    return false;
}
 
Example 16
public static boolean handleProxyIntent(Activity activity, Intent intent) {
    if (intent == null) {
        return false;
    }
    try {
        if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
            return false;
        }
        Uri data = intent.getData();
        if (data != null) {
            String user = null;
            String password = null;
            String port = null;
            String address = null;
            String secret = null;
            String scheme = data.getScheme();
            if (scheme != null) {
                if ((scheme.equals("http") || scheme.equals("https"))) {
                    String host = data.getHost().toLowerCase();
                    if (host.equals("telegram.me") || host.equals("t.me") || host.equals("telegram.dog")) {
                        String path = data.getPath();
                        if (path != null) {
                            if (path.startsWith("/socks") || path.startsWith("/proxy")) {
                                address = data.getQueryParameter("server");
                                port = data.getQueryParameter("port");
                                user = data.getQueryParameter("user");
                                password = data.getQueryParameter("pass");
                                secret = data.getQueryParameter("secret");
                            }
                        }
                    }
                } else if (scheme.equals("tg")) {
                    String url = data.toString();
                    if (url.startsWith("tg:proxy") || url.startsWith("tg://proxy") || url.startsWith("tg:socks") || url.startsWith("tg://socks")) {
                        url = url.replace("tg:proxy", "tg://telegram.org").replace("tg://proxy", "tg://telegram.org").replace("tg://socks", "tg://telegram.org").replace("tg:socks", "tg://telegram.org");
                        data = Uri.parse(url);
                        address = data.getQueryParameter("server");
                        port = data.getQueryParameter("port");
                        user = data.getQueryParameter("user");
                        password = data.getQueryParameter("pass");
                        secret = data.getQueryParameter("secret");
                    }
                }
            }
            if (!TextUtils.isEmpty(address) && !TextUtils.isEmpty(port)) {
                if (user == null) {
                    user = "";
                }
                if (password == null) {
                    password = "";
                }
                if (secret == null) {
                    secret = "";
                }
                showProxyAlert(activity, address, port, user, password, secret);
                return true;
            }
        }
    } catch (Exception ignore) {

    }
    return false;
}
 
Example 17
public static boolean handleProxyIntent(Activity activity, Intent intent) {
    if (intent == null) {
        return false;
    }
    try {
        if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
            return false;
        }
        Uri data = intent.getData();
        if (data != null) {
            String user = null;
            String password = null;
            String port = null;
            String address = null;
            String secret = null;
            String scheme = data.getScheme();
            if (scheme != null) {
                if ((scheme.equals("http") || scheme.equals("https"))) {
                    String host = data.getHost().toLowerCase();
                    if (host.equals("telegram.me") || host.equals("t.me") || host.equals("telegram.dog")) {
                        String path = data.getPath();
                        if (path != null) {
                            if (path.startsWith("/socks") || path.startsWith("/proxy")) {
                                address = data.getQueryParameter("server");
                                port = data.getQueryParameter("port");
                                user = data.getQueryParameter("user");
                                password = data.getQueryParameter("pass");
                                secret = data.getQueryParameter("secret");
                            }
                        }
                    }
                } else if (scheme.equals("tg")) {
                    String url = data.toString();
                    if (url.startsWith("tg:proxy") || url.startsWith("tg://proxy") || url.startsWith("tg:socks") || url.startsWith("tg://socks")) {
                        url = url.replace("tg:proxy", "tg://telegram.org").replace("tg://proxy", "tg://telegram.org").replace("tg://socks", "tg://telegram.org").replace("tg:socks", "tg://telegram.org");
                        data = Uri.parse(url);
                        address = data.getQueryParameter("server");
                        port = data.getQueryParameter("port");
                        user = data.getQueryParameter("user");
                        password = data.getQueryParameter("pass");
                        secret = data.getQueryParameter("secret");
                    }
                }
            }
            if (!TextUtils.isEmpty(address) && !TextUtils.isEmpty(port)) {
                if (user == null) {
                    user = "";
                }
                if (password == null) {
                    password = "";
                }
                if (secret == null) {
                    secret = "";
                }
                showProxyAlert(activity, address, port, user, password, secret);
                return true;
            }
        }
    } catch (Exception ignore) {

    }
    return false;
}
 
Example 18
Source Project: Ansole   File: Term.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void populateViewFlipper() {
    if (mTermService != null) {
        mTermSessions = mTermService.getSessions();
        mTermSessions.addCallback(this);

        if (mTermSessions.size() == 0) {
            try {
                mTermSessions.add(createTermSession());
            } catch (IOException e) {
                Toast.makeText(this, "Failed to start terminal session", Toast.LENGTH_LONG).show();
                finish();
                return;
            }
        }

        for (TermSession session : mTermSessions) {
            EmulatorView view = createEmulatorView(session);
            mViewFlipper.addView(view);
        }

        updatePrefs();

        Intent intent = getIntent();
        int flags = intent.getFlags();
        String action = intent.getAction();
        if ((flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0
                && action != null) {
            if (action.equals(RemoteInterface.PRIVATE_OPEN_NEW_WINDOW)) {
                mViewFlipper.setDisplayedChild(mTermSessions.size() - 1);
            } else if (action.equals(RemoteInterface.PRIVATE_SWITCH_WINDOW)) {
                int target = intent.getIntExtra(
                        RemoteInterface.PRIVATE_EXTRA_TARGET_WINDOW, -1);
                if (target >= 0) {
                    mViewFlipper.setDisplayedChild(target);
                }
            }
        }

        mViewFlipper.resumeCurrentView();
    }
}
 
Example 19
Source Project: 365browser   File: ChromeTabbedActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void preInflationStartup() {
    super.preInflationStartup();

    // Decide whether to record startup UMA histograms. This is done  early in the main
    // Activity.onCreate() to avoid recording navigation delays when they require user input to
    // proceed. For example, FRE (First Run Experience) happens before the activity is created,
    // and triggers initialization of the native library. At the moment it seems safe to assume
    // that uninitialized native library is an indication of an application start that is
    // followed by navigation immediately without user input.
    if (!LibraryLoader.isInitialized()) {
        UmaUtils.setRunningApplicationStart(true);
    }

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS)
            && getIntent() != null
            && getIntent().hasExtra(
                    ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT)) {
        int value = getIntent().getIntExtra(
                ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT, -1);
        if (value != -1) {
            String[] args = new String[1];
            args[0] = "--" + ContentSwitches.RENDER_PROCESS_LIMIT
                    + "=" + Integer.toString(value);
            commandLine.appendSwitchesAndArguments(args);
        }
    }

    supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);

    // We are starting from history with a URL after data has been cleared. On Samsung this
    // can happen after user clears data and clicks on a recents item on pre-L devices.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
            && getIntent().getData() != null
            && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0
            && OmahaBase.isProbablyFreshInstall(this)) {
        getIntent().setData(null);
    }

    launchFirstRunExperience();
}
 
Example 20
/**
 * Checks whether this activity is launched from the history.
 *
 * @return {@code true} if this activity is launched from the history.
 */
public boolean isLaunchedFromHistory() {
    return getIntent() != null && (getIntent().getFlags()
            & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0;
}