List of usage examples for android.content Intent ACTION_MAIN
String ACTION_MAIN
To view the source code for android.content Intent ACTION_MAIN.
Click Source Link
From source file:com.android.soma.Launcher.java
@Override protected void onNewIntent(Intent intent) { long startTime = 0; if (DEBUG_RESUME_TIME) { startTime = System.currentTimeMillis(); }//from w w w . ja v a 2 s .c om super.onNewIntent(intent); // Close the menu if (Intent.ACTION_MAIN.equals(intent.getAction())) { // also will cancel mWaitingForResult. closeSystemDialogs(); final boolean alreadyOnHome = mHasFocus && ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); if (mWorkspace == null) { // Can be cases where mWorkspace is null, this prevents a NPE return; } Folder openFolder = mWorkspace.getOpenFolder(); // In all these cases, only animate if we're already on home mWorkspace.exitWidgetResizeMode(); if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && openFolder == null) { mWorkspace.moveToDefaultScreen(true); } closeFolder(); exitSpringLoadedDragMode(); // If we are already on home, then just animate back to the workspace, // otherwise, just wait until onResume to set the state back to Workspace if (alreadyOnHome) { showWorkspace(true); } else { mOnResumeState = State.WORKSPACE; } final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } // Reset the apps customize page if (mAppsCustomizeTabHost != null) { mAppsCustomizeTabHost.reset(); } } if (DEBUG_RESUME_TIME) { Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime)); } }
From source file:mp.teardrop.PlaybackService.java
/** * Create a PendingIntent for use with the notification. * * @param prefs Where to load the action preference from. *///from w w w .j a va 2 s . c o m public PendingIntent createNotificationAction(SharedPreferences prefs) { switch (Integer.parseInt(prefs.getString(PrefKeys.NOTIFICATION_ACTION, "0"))) { case NOT_ACTION_NEXT_SONG: { Intent intent = new Intent(this, PlaybackService.class); intent.setAction(PlaybackService.ACTION_NEXT_SONG_AUTOPLAY); return PendingIntent.getService(this, 0, intent, 0); } case NOT_ACTION_MINI_ACTIVITY: { Intent intent = new Intent(this, MiniPlaybackActivity.class); return PendingIntent.getActivity(this, 0, intent, 0); } default: Log.w("OrchidMP", "Unknown value for notification_action. Defaulting to 0."); // fall through case NOT_ACTION_MAIN_ACTIVITY: { Intent intent = new Intent(this, LibraryActivity.class); intent.setAction(Intent.ACTION_MAIN); return PendingIntent.getActivity(this, 0, intent, 0); } case NOT_ACTION_FULL_ACTIVITY: { Intent intent = new Intent(this, FullPlaybackActivity.class); intent.setAction(Intent.ACTION_MAIN); return PendingIntent.getActivity(this, 0, intent, 0); } } }
From source file:com.android.launcher2.Launcher.java
void processShortcut(Intent intent) { // Handle case where user selected "Applications" String applicationName = getResources().getString(R.string.group_applications); String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (applicationName != null && applicationName.equals(shortcutName)) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY); pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent); pickIntent.putExtra(Intent.EXTRA_TITLE, getText(R.string.title_select_application)); startActivityForResultSafely(pickIntent, REQUEST_PICK_APPLICATION); } else {// ww w .ja v a2s . co m startActivityForResultSafely(intent, REQUEST_CREATE_SHORTCUT); } }
From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java
private boolean setScreenSwitchToHome() { // moveTaskToBack(true); Handler hndl = new Handler(); hndl.postDelayed(new Runnable() { @Override/*from w w w .jav a 2 s. c om*/ public void run() { Intent in = new Intent(); in.setAction(Intent.ACTION_MAIN); in.addCategory(Intent.CATEGORY_HOME); startActivity(in); } }, 100); return true; }
From source file:com.sentaroh.android.TaskAutomation.TaskExecutor.java
final static public boolean setScreenSwitchToHome(TaskManagerParms taskMgrParms, EnvironmentParms envParms, CommonUtilities util, TaskResponse taskResponse, ActionResponse ar) { Intent in = new Intent(); in.setAction(Intent.ACTION_MAIN); in.addCategory(Intent.CATEGORY_HOME); in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); taskMgrParms.context.startActivity(in); return true;// ww w . j a v a 2 s. c o m }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
@Override protected void onNewIntent(Intent intent) { long startTime = 0; if (DEBUG_RESUME_TIME) { startTime = System.currentTimeMillis(); }/*from w w w . jav a 2 s . com*/ super.onNewIntent(intent); // Close the menu if (Intent.ACTION_MAIN.equals(intent.getAction())) { final boolean alreadyOnHome = mHasFocus && ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); if (mLauncherDrawer.isDrawerOpen(Gravity.LEFT)) { new Handler().postDelayed(new Runnable() { @Override public void run() { mLauncherDrawer.closeDrawer(Gravity.LEFT); } }, 300); return; } else if (mLauncherDrawer.isDrawerOpen(Gravity.RIGHT)) { new Handler().postDelayed(new Runnable() { @Override public void run() { mLauncherDrawer.closeDrawer(Gravity.RIGHT); } }, 300); return; } else if (!isAllAppsVisible() && alreadyOnHome && mWorkspace.getCurrentPage() == 0 && !mWorkspace.isInOverviewMode()) { new Handler().postDelayed(new Runnable() { @Override public void run() { GestureUtils.runGesture(Launcher.this, Launcher.this, AppSettings.HOME_BUTTON); } }, 300); return; } // also will cancel mWaitingForResult. closeSystemDialogs(); if (mWorkspace == null) { // Can be cases where mWorkspace is null, this prevents a NPE return; } Folder openFolder = mWorkspace.getOpenFolder(); // In all these cases, only animate if we're already on home mWorkspace.exitWidgetResizeMode(); boolean moveToDefaultScreen = mLauncherCallbacks != null ? mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent() : true; if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && openFolder == null && moveToDefaultScreen) { mWorkspace.moveToDefaultScreen(true); } closeFolder(); exitSpringLoadedDragMode(); // If we are already on home, then just animate back to the workspace, // otherwise, just wait until onResume to set the state back to Workspace if (alreadyOnHome) { showWorkspace(true); } else { mOnResumeState = State.WORKSPACE; } final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } // Reset the apps view if (!alreadyOnHome && mAppsView != null) { mAppsView.scrollToTop(); } // Reset the widgets view if (!alreadyOnHome && mWidgetsView != null) { mWidgetsView.scrollToTop(); } if (mLauncherCallbacks != null) { mLauncherCallbacks.onHomeIntent(); } } if (DEBUG_RESUME_TIME) { Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime)); } if (mLauncherCallbacks != null) { mLauncherCallbacks.onNewIntent(intent); } }
From source file:org.mozilla.gecko.GeckoApp.java
@Override protected void onNewIntent(Intent intent) { Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onNewIntent"); if (checkLaunchState(LaunchState.GeckoExiting)) { // We're exiting and shouldn't try to do anything else just incase // we're hung for some reason we'll force the process to exit System.exit(0);/*from w w w . j a v a 2 s . co m*/ return; } if (checkLaunchState(LaunchState.Launched)) { Uri data = intent.getData(); Bundle bundle = intent.getExtras(); // if the intent has data (i.e. a URI to be opened) and the scheme // is either http, we'll prefetch it, which means warming // up the radio and DNS cache by connecting and parsing the redirect // if the return code is between 300 and 400 if (data != null && "http".equals(data.getScheme()) && (bundle == null || bundle.getInt("prefetched", 0) != 1) && isHostOnPrefetchWhitelist(data.getHost())) { GeckoAppShell.getHandler().post(new RedirectorRunnable(intent)); return; } } final String action = intent.getAction(); if (ACTION_DEBUG.equals(action) && checkAndSetLaunchState(LaunchState.Launching, LaunchState.WaitForDebugger)) { mMainHandler.postDelayed(new Runnable() { public void run() { Log.i(LOGTAG, "Launching from debug intent after 5s wait"); setLaunchState(LaunchState.Launching); sGeckoThread.start(); } }, 1000 * 5 /* 5 seconds */); Log.i(LOGTAG, "Intent : ACTION_DEBUG - waiting 5s before launching"); return; } if (checkLaunchState(LaunchState.WaitForDebugger) || intent == getIntent()) return; if (Intent.ACTION_MAIN.equals(action)) { Log.i(LOGTAG, "Intent : ACTION_MAIN"); GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent("")); } else if (ACTION_LOAD.equals(action)) { String uri = intent.getDataString(); loadUrl(uri, AwesomeBar.Type.EDIT); Log.i(LOGTAG, "onNewIntent: " + uri); } else if (Intent.ACTION_VIEW.equals(action)) { String uri = intent.getDataString(); GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(uri)); Log.i(LOGTAG, "onNewIntent: " + uri); } else if (ACTION_WEBAPP.equals(action)) { String uri = getURIFromIntent(intent); GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(uri)); Log.i(LOGTAG, "Intent : WEBAPP - " + uri); } else if (ACTION_BOOKMARK.equals(action)) { String uri = getURIFromIntent(intent); GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(uri)); Log.i(LOGTAG, "Intent : BOOKMARK - " + uri); } }
From source file:com.android.launcher3.Launcher.java
@Override protected void onNewIntent(Intent intent) { long startTime = 0; if (DEBUG_RESUME_TIME) { startTime = System.currentTimeMillis(); }/* ww w . j a v a 2 s.c o m*/ super.onNewIntent(intent); boolean alreadyOnHome = mHasFocus && ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); // Check this condition before handling isActionMain, as this will get reset. boolean shouldMoveToDefaultScreen = alreadyOnHome && mState == State.WORKSPACE && getTopFloatingView() == null; boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction()); if (isActionMain) { // also will cancel mWaitingForResult. closeSystemDialogs(); if (mWorkspace == null) { // Can be cases where mWorkspace is null, this prevents a NPE return; } // In all these cases, only animate if we're already on home mWorkspace.exitWidgetResizeMode(); closeFolder(alreadyOnHome); closeShortcutsContainer(alreadyOnHome); exitSpringLoadedDragMode(); // If we are already on home, then just animate back to the workspace, // otherwise, just wait until onResume to set the state back to Workspace if (alreadyOnHome) { showWorkspace(true); } else { mOnResumeState = State.WORKSPACE; } final View v = getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } // Reset the apps view if (!alreadyOnHome && mAppsView != null) { mAppsView.scrollToTop(); } // Reset the widgets view if (!alreadyOnHome && mWidgetsView != null) { mWidgetsView.scrollToTop(); } if (mLauncherCallbacks != null) { mLauncherCallbacks.onHomeIntent(); } } if (mLauncherCallbacks != null) { mLauncherCallbacks.onNewIntent(intent); } // Defer moving to the default screen until after we callback to the LauncherCallbacks // as slow logic in the callbacks eat into the time the scroller expects for the snapToPage // animation. if (isActionMain) { boolean callbackAllowsMoveToDefaultScreen = mLauncherCallbacks != null ? mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent() : true; if (shouldMoveToDefaultScreen && !mWorkspace.isTouchActive() && callbackAllowsMoveToDefaultScreen) { // We use this flag to suppress noisy callbacks above custom content state // from onResume. mMoveToDefaultScreenFromNewIntent = true; mWorkspace.post(new Runnable() { @Override public void run() { if (mWorkspace != null) { mWorkspace.moveToDefaultScreen(true); } } }); } } if (DEBUG_RESUME_TIME) { Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime)); } }
From source file:com.cognizant.trumobi.PersonaLauncher.java
void processShortcut(Intent intent, int requestCodeApplication, int requestCodeShortcut) { PersonaLog.e(LOG_TAG, "processShortcut" + intent); // Handle case where user selected "Applications" String applicationName = getResources().getString(R.string.group_applications); String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (applicationName != null && applicationName.equals(shortcutName)) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); // 290778 modified for shortcut /*//w ww. j av a2 s .c o m * Intent mainIntent = new Intent("Email"); * mainIntent.addCategory("android.intent.category.PIM"); */ Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY); pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent); pickIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.group_applications)); startActivityForResult(pickIntent, requestCodeApplication); } else { startActivityForResult(intent, requestCodeShortcut); } }
From source file:com.android.soma.Launcher.java
void processShortcut(Intent intent) { // Handle case where user selected "Applications" String applicationName = getResources().getString(R.string.group_applications); String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (applicationName != null && applicationName.equals(shortcutName)) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY); pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent); pickIntent.putExtra(Intent.EXTRA_TITLE, getText(R.string.title_select_application)); Utilities.startActivityForResultSafely(this, pickIntent, REQUEST_PICK_APPLICATION); } else {/* w w w . j a v a2 s . com*/ Utilities.startActivityForResultSafely(this, intent, REQUEST_CREATE_SHORTCUT); } }