// Possible work around for market launches. See http://code.google.com/p/android/issues/detail?id=2373 // for more details. Essentially, the market launches the main activity on top of other activities. // we never want this to happen. Instead, we check if we are the root and if not, we finish. if (!isTaskRoot()) { final Intent intent = getIntent(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) { Log.w(LOG_TAG, "Main Activity is not the root. Finishing Main Activity instead of launching."); finish(); return; } }
if (!isTaskRoot()) { Intent intent = getIntent(); String action = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action != null && action.equals(Intent.ACTION_MAIN)) { finish(); return; } }
@Override protected void onNewIntent(Intent intent) { if (DEBUG) Log.d(TAG, "onNewIntent() called with: intent = [" + intent + "]"); if (intent != null) { // Return if launched from a launcher (e.g. Nova Launcher, Pixel Launcher ...) // to not destroy the already created backstack String action = intent.getAction(); if ((action != null && action.equals(Intent.ACTION_MAIN)) && intent.hasCategory(Intent.CATEGORY_LAUNCHER)) return; } super.onNewIntent(intent); setIntent(intent); handleIntent(intent); }
@Override public boolean onControlRequest(Intent i, ControlRequestCallback cb) { if (i.hasCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)) { if (MediaControlIntent.ACTION_PLAY.equals(i.getAction())) { return(onPlayRequest(i, cb)); } else if (MediaControlIntent.ACTION_PAUSE.equals(i.getAction())) { return(onPauseRequest(i, cb)); } else if (MediaControlIntent.ACTION_RESUME.equals(i.getAction())) { return(onResumeRequest(i, cb)); } else if (MediaControlIntent.ACTION_STOP.equals(i.getAction())) { return(onStopRequest(i, cb)); } else if (MediaControlIntent.ACTION_GET_STATUS.equals(i.getAction())) { return(onGetStatusRequest(i, cb)); } else if (MediaControlIntent.ACTION_SEEK.equals(i.getAction())) { return(onSeekRequest(i, cb)); } } Log.w(getClass().getSimpleName(), "unexpected control request" + i.toString()); return(false); }
@Override public boolean onControlRequest(Intent i, ControlRequestCallback cb) { if (i.hasCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)) { if (MediaControlIntent.ACTION_PLAY.equals(i.getAction())) { return(onPlayRequest(i, cb)); } else if (MediaControlIntent.ACTION_PAUSE.equals(i.getAction())) { return(onPauseRequest(i, cb)); } else if (MediaControlIntent.ACTION_RESUME.equals(i.getAction())) { return(onResumeRequest(i, cb)); } else if (MediaControlIntent.ACTION_STOP.equals(i.getAction())) { return(onStopRequest(i, cb)); } else if (MediaControlIntent.ACTION_GET_STATUS.equals(i.getAction())) { return(onGetStatusRequest(i, cb)); } else if (MediaControlIntent.ACTION_SEEK.equals(i.getAction())) { return(onSeekRequest(i, cb)); } } Log.w(getClass().getSimpleName(), "unexpected control request" + i.toString()); return(false); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = getIntent(); final Uri data = intent.getData(); final Intent newIntent = getIntentForURI(data); if (newIntent != null) { startActivity(newIntent); finish(); return; } if (!intent.hasCategory(CATEGORY_BROWSABLE)) { startActivity(new Intent(ACTION_VIEW, data).addCategory(CATEGORY_BROWSABLE)); finish(); } else { showParseError(data.toString()); } }
@Test public void shouldSupportCategories() throws Exception { Intent intent = new Intent(); Intent self = intent.addCategory("category.name.1"); intent.addCategory("category.name.2"); assertTrue(intent.hasCategory("category.name.1")); assertTrue(intent.hasCategory("category.name.2")); Set<String> categories = intent.getCategories(); assertTrue(categories.contains("category.name.1")); assertTrue(categories.contains("category.name.2")); intent.removeCategory("category.name.1"); assertFalse(intent.hasCategory("category.name.1")); assertTrue(intent.hasCategory("category.name.2")); intent.removeCategory("category.name.2"); assertFalse(intent.hasCategory("category.name.2")); assertThat(intent.getCategories()).isNull(); assertSame(self, intent); }
if (intent.hasCategory(Intent.CATEGORY_ALTERNATIVE)) { Uri data = intent.getData(); int buttonId = Integer.parseInt(data.getSchemeSpecificPart());
Intent intent = getIntent(); if (Intent.ACTION_MAIN.equals(intent.getAction()) && intent.hasCategory(Intent.CATEGORY_LAUNCHER)) { // started by launcher }
if (!isTaskRoot()) { final Intent intent = getIntent(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) { finish(); return; } }
if (!isTaskRoot()) { final Intent intent = getIntent(); final String intentAction = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) { Log.w(LOG_TAG, "Main Activity is not the root. Finishing Main Activity instead of launching."); finish(); return; } }
if (!isTaskRoot()) { final Intent intent = getIntent(); final String intentAction = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) { finish(); return; } }
// Possible work around for market launches. See http://code.google.com/p/android/issues/detail?id=2373 // for more details. Essentially, the market launches the main activity on top of other activities. // we never want this to happen. Instead, we check if we are the root and if not, we finish. if (!isTaskRoot()) { final Intent intent = getIntent(); final String intentAction = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) { finish(); return; } }
if (!isTaskRoot()) { final Intent intent = getIntent(); final String intentAction = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) { finish(); } }
if (!isTaskRoot()) { Intent intent = getIntent(); String action = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action != null && action.equals(Intent.ACTION_MAIN)) { finish(); return; } }
if (!isTaskRoot()) { final Intent intent = getIntent(); final String intentAction = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) { finish(); return; } }
if (!isTaskRoot()) { Intent intent = getIntent(); String action = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action != null && action.equals(Intent.ACTION_MAIN)) { finish(); return; } }
if (!isTaskRoot()) { final Intent intent = getIntent(); final String intentAction = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) { Log.w(LOG_TAG, "Main Activity is not the root. Finishing Main Activity instead of launching."); finish(); return; } }
if (isTaskRoot()) { final Intent intent = getIntent(); final String intentAction = intent.getAction(); if (!intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) { finish(); System.exit(0); } }
Put below code on the onCreate() of launcher activity- final Intent intent = getIntent(); if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0 && intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_MAIN)) { finish();// finish this launcher activity return; }