List of usage examples for android.content Intent FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
To view the source code for android.content Intent FLAG_ACTIVITY_RESET_TASK_IF_NEEDED.
Click Source Link
From source file:com.saulcintero.moveon.services.MoveOnService.java
private void showNotification() { NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_silhouette).setContentTitle(getString(R.string.app_complete_name)) .setContentText(getString(R.string.local_service_started)).setOngoing(true); Intent notificationIntent = new Intent(mContext, SplashScreen.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent pIntent = PendingIntent.getActivity(mContext, NOTIFICATION_ID, notificationIntent, 0); builder.setContentIntent(pIntent);// w ww . ja va2s. c om Notification notif = builder.build(); mNotificationManager.notify(NOTIFICATION_ID, notif); }
From source file:com.sentaroh.android.TaskAutomation.TaskExecutor.java
final static private void executeAndroidActivity(TaskManagerParms taskMgrParms, EnvironmentParms envParms, CommonUtilities util, TaskResponse task_response, ActionResponse ar, String task, String pkg, TaskActionItem eali) {/*from w w w . j a v a 2 s . c o m*/ util.addLogMsg("I", String.format(taskMgrParms.teMsgs.msgs_thread_task_exec_android, task, pkg)); final PackageManager pm = taskMgrParms.context.getPackageManager(); Intent in = pm.getLaunchIntentForPackage(pkg); ar.action_resp = ActionResponse.ACTION_SUCCESS; if (in != null) { in.setAction(Intent.ACTION_MAIN); in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); if (eali.action_activity_data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_URI)) { in.setData(Uri.parse(eali.action_activity_data_uri)); if (envParms.settingDebugLevel >= 1) util.addDebugMsg(1, "I", " Uri data added : Uri=", eali.action_activity_data_uri); } else if (eali.action_activity_data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_EXTRA)) { ArrayList<ActivityExtraDataItem> aed_list = eali.action_activity_data_extra_list; for (int i = 0; i < aed_list.size(); i++) { ActivityExtraDataItem aedi = aed_list.get(i); if (aedi.data_value_array.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_ARRAY_NO)) { String d_val_string = ""; boolean d_val_boolean = false; int d_val_int = 0; if (aedi.data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { d_val_string = aedi.data_value; in.putExtra(aedi.key_value, d_val_string); if (envParms.settingDebugLevel >= 1) util.addDebugMsg(1, "I", " Extra String data added : key=", aedi.key_value, ", value=", d_val_string); } else if (aedi.data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) { d_val_int = Integer.valueOf(aedi.data_value); in.putExtra(aedi.key_value, d_val_int); if (envParms.settingDebugLevel >= 1) util.addDebugMsg(1, "I", " Extra Int data added : key=", aedi.key_value, ", value=", String.valueOf(d_val_int)); } else if (aedi.data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) { if (aedi.data_value.equals("true")) d_val_boolean = true; in.putExtra(aedi.key_value, d_val_boolean); if (envParms.settingDebugLevel >= 1) util.addDebugMsg(1, "I", " Extra Boolean data added : key=", aedi.key_value, ", value=", String.valueOf(d_val_boolean)); } } else if (aedi.data_value_array .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_ARRAY_YES)) { if (aedi.data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { String[] d_val_array = aedi.data_value.split("\u0003"); String[] d_val_extra = new String[d_val_array.length]; for (int ai = 0; ai < d_val_array.length; ai++) { d_val_extra[ai] = d_val_array[ai]; if (envParms.settingDebugLevel >= 1) util.addDebugMsg(1, "I", " Extra array String data added : key=", aedi.key_value, ", value=", d_val_extra[ai]); } in.putExtra(aedi.key_value, d_val_extra); } else if (aedi.data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) { String[] d_val_array = aedi.data_value.split("\u0003"); int[] d_val_extra = new int[d_val_array.length]; for (int ai = 0; ai < d_val_array.length; ai++) { d_val_extra[ai] = Integer.valueOf(d_val_array[ai]); if (envParms.settingDebugLevel >= 1) util.addDebugMsg(1, "I", " Extra array Int data added : key=", aedi.key_value, ", value=", String.valueOf(d_val_extra[ai])); } in.putExtra(aedi.key_value, d_val_extra); } else if (aedi.data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) { String[] d_val_array = aedi.data_value.split("\u0003"); boolean[] d_val_extra = new boolean[d_val_array.length]; for (int ai = 0; ai < d_val_array.length; ai++) { if (d_val_array[ai].equals("true")) d_val_extra[ai] = true; else d_val_extra[ai] = false; if (envParms.settingDebugLevel >= 1) util.addDebugMsg(1, "I", " Extra array Boolean data added : key=", aedi.key_value, ", value=", String.valueOf(d_val_extra[ai])); } in.putExtra(aedi.key_value, d_val_extra); } } } } else { if (envParms.settingDebugLevel >= 1) util.addDebugMsg(1, "I", " No data was supplied"); } taskMgrParms.context.startActivity(in); task_response.active_thread_ctrl.setThreadResultSuccess(); waitTimeTc(task_response, 100); } else { String msg = String.format(taskMgrParms.teMsgs.msgs_thread_task_intent_notfound, pkg); util.addLogMsg("E", msg); ar.action_resp = ActionResponse.ACTION_ERROR; ar.resp_msg_text = msg; } }
From source file:org.jsharkey.grouphome.LauncherActivity.java
public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); Intent homeIntent = new Intent(); homeIntent.setClassName("com.android.launcher", "com.android.launcher.Launcher"); menu.add("Default home").setIcon(R.drawable.ic_menu_home).setIntent(homeIntent); menu.add("Search").setIcon(android.R.drawable.ic_menu_search); force = menu.add("Expand all").setIcon(android.R.drawable.ic_menu_share) .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { ExpandableListView listView = LauncherActivity.this.getExpandableListView(); ExpandableListAdapter adapter = LauncherActivity.this.getExpandableListAdapter(); switch (expandState) { case STATE_UNKNOWN: case STATE_ALL_COLLAP: // when unknown or collapsed, we force all open for (int i = 0; i < adapter.getGroupCount(); i++) listView.expandGroup(i); expandState = STATE_ALL_EXPAND; break; case STATE_ALL_EXPAND: // when expanded, we force all closed for (int i = 0; i < adapter.getGroupCount(); i++) listView.collapseGroup(i); expandState = STATE_ALL_COLLAP; break; }/*w w w . j av a 2s .co m*/ return true; } }); menu.add("Refresh").setIcon(R.drawable.ic_menu_refresh) .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // clear any database mappings and local json cache // TODO: clear local json cache (when implemented) appdb.deleteAllMappings(); setListAdapter(null); new ProcessTask().execute(); return true; } }); Intent settingsIntent = new Intent(android.provider.Settings.ACTION_SETTINGS); settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); menu.add("Settings").setIcon(android.R.drawable.ic_menu_preferences).setIntent(settingsIntent); return true; }
From source file:com.mobiletin.inputmethod.indic.settings.CustomInputStyleSettingsFragment.java
private AlertDialog createDialog() { final AlertDialog.Builder builder = new AlertDialog.Builder( DialogUtils.getPlatformDialogThemeContext(getActivity())); builder.setTitle(R.string.custom_input_styles_title).setMessage(R.string.custom_input_style_note_message) .setNegativeButton(R.string.not_now, null) .setPositiveButton(R.string.enable, new DialogInterface.OnClickListener() { @Override//from w w w .j a v a2 s . co m public void onClick(DialogInterface dialog, int which) { final Intent intent = IntentUtils.getInputLanguageSelectionIntent( mRichImm.getInputMethodIdOfThisIme(), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); // TODO: Add newly adding subtype to extra value of the intent as a hint // for the input language selection activity. // intent.putExtra("newlyAddedSubtype", subtypePref.getSubtype()); startActivity(intent); } }); return builder.create(); }
From source file:com.udmurtlyk.extrainputmethod.latin.settings.CustomInputStyleSettingsFragment.java
private AlertDialog createDialog() { final AlertDialog.Builder builder = new AlertDialog.Builder( DialogUtils.getPlatformDialogThemeContext(getActivity())); builder.setTitle(com.udmurtlyk.extrainputmethod.latin.R.string.custom_input_styles_title) .setMessage(com.udmurtlyk.extrainputmethod.latin.R.string.custom_input_style_note_message) .setNegativeButton(com.udmurtlyk.extrainputmethod.latin.R.string.not_now, null) .setPositiveButton(com.udmurtlyk.extrainputmethod.latin.R.string.enable, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Intent intent = IntentUtils .getInputLanguageSelectionIntent(mRichImm.getInputMethodIdOfThisIme(), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); // TODO: Add newly adding subtype to extra value of the intent as a hint // for the input language selection activity. // intent.putExtra("newlyAddedSubtype", subtypePref.getSubtype()); startActivity(intent); }/* w w w. j a v a 2 s .co m*/ }); return builder.create(); }
From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java
private boolean openApp() { final Intent launchIntent = pinpointContext.getApplicationContext().getPackageManager() .getLaunchIntentForPackage(pinpointContext.getApplicationContext().getPackageName()); if (launchIntent == null) { log.error("Couldn't get app launch intent for campaign notification."); return false; }/*w ww. j a va2 s. c o m*/ launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); launchIntent.setPackage(null); pinpointContext.getApplicationContext().startActivity(launchIntent); return true; }
From source file:org.jsharkey.grouphome.LauncherActivity.java
public void onClick(View v) { if (!(v.getTag() instanceof EntryInfo)) return;/*from w ww. j a va 2 s .c o m*/ EntryInfo info = (EntryInfo) v.getTag(); // build actual intent for launching app Intent launch = new Intent(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.setComponent(new ComponentName(info.resolveInfo.activityInfo.applicationInfo.packageName, info.resolveInfo.activityInfo.name)); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); try { this.startActivity(launch); } catch (Exception e) { Toast.makeText(this, "Problem trying to launch application", Toast.LENGTH_SHORT).show(); Log.e(TAG, "Problem trying to launch application", e); } }
From source file:com.android.launcher2.Launcher.java
/** * Add an application shortcut to the workspace. * * @param data The intent describing the application. * @param cellInfo The position on screen where to create the shortcut. */// ww w.ja va 2s. c o m void completeAddApplication(Intent data, long container, int screen, int cellX, int cellY) { final int[] cellXY = mTmpAddItemCellCoordinates; final CellLayout layout = getCellLayout(container, screen); // First we check if we already know the exact location where we want to add this item. if (cellX >= 0 && cellY >= 0) { cellXY[0] = cellX; cellXY[1] = cellY; } else if (!layout.findCellForSpan(cellXY, 1, 1)) { showOutOfSpaceMessage(isHotseatLayout(layout)); return; } final ShortcutInfo info = mModel.getShortcutInfo(getPackageManager(), data, this); if (info != null) { info.setActivity(data.getComponent(), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); info.container = ItemInfo.NO_ID; mWorkspace.addApplicationShortcut(info, layout, container, screen, cellXY[0], cellXY[1], isWorkspaceLocked(), cellX, cellY); } else { Log.e(TAG, "Couldn't find ActivityInfo for selected application: " + data); } }
From source file:com.cognizant.trumobi.PersonaLauncher.java
private static PersonaApplicationInfo infoFromApplicationIntent(Context context, Intent data) { ComponentName component = data.getComponent(); PackageManager packageManager = context.getPackageManager(); ActivityInfo activityInfo = null;//from w w w .j ava2s . c om try { activityInfo = packageManager.getActivityInfo(component, 0 /* * no * flags */); } catch (NameNotFoundException e) { PersonaLog.e(LOG_TAG, "Couldn't find ActivityInfo for selected application", e); } if (activityInfo != null) { PersonaApplicationInfo itemInfo = new PersonaApplicationInfo(); itemInfo.title = activityInfo.loadLabel(packageManager); if (itemInfo.title == null) { itemInfo.title = activityInfo.name; } itemInfo.setActivity(component, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); // itemInfo.icon = activityInfo.loadIcon(packageManager); itemInfo.container = PersonaItemInfo.NO_ID; itemInfo.icon = PersonaLauncherModel.getIcon(packageManager, context, activityInfo); return itemInfo; } return null; }
From source file:com.android.soma.Launcher.java
/** * Add an application shortcut to the workspace. * * @param data The intent describing the application. * @param cellInfo The position on screen where to create the shortcut. *//*from w ww.j a v a 2 s . c o m*/ void completeAddApplication(Intent data, long container, long screenId, int cellX, int cellY) { final int[] cellXY = mTmpAddItemCellCoordinates; final CellLayout layout = getCellLayout(container, screenId); // First we check if we already know the exact location where we want to add this item. if (cellX >= 0 && cellY >= 0) { cellXY[0] = cellX; cellXY[1] = cellY; } else if (!layout.findCellForSpan(cellXY, 1, 1)) { showOutOfSpaceMessage(isHotseatLayout(layout)); return; } final ShortcutInfo info = mModel.getShortcutInfo(getPackageManager(), data, this); if (info != null) { info.setActivity(this, data.getComponent(), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); info.container = ItemInfo.NO_ID; mWorkspace.addApplicationShortcut(info, layout, container, screenId, cellXY[0], cellXY[1], isWorkspaceLocked(), cellX, cellY); } else { Log.e(TAG, "Couldn't find ActivityInfo for selected application: " + data); } }