List of usage examples for android.content Intent FLAG_ACTIVITY_MULTIPLE_TASK
int FLAG_ACTIVITY_MULTIPLE_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_MULTIPLE_TASK.
Click Source Link
From source file:net.olejon.mdapp.NotesEditActivity.java
private void getMedications() { try {//w ww .java 2 s.c om int medicationsJsonArrayLength = mPatientMedicationsJsonArray.length(); if (medicationsJsonArrayLength == 0) { mPatientMedicationsTextView.setVisibility(View.GONE); } else { mPatientMedicationsTextView.setVisibility(View.VISIBLE); final ArrayList<String> medicationsNamesArrayList = new ArrayList<>(); final ArrayList<String> medicationsManufacturersArrayList = new ArrayList<>(); final String[] medicationsNamesStringArrayList = new String[medicationsJsonArrayLength + 2]; medicationsNamesStringArrayList[0] = getString(R.string.notes_edit_medications_dialog_interactions); medicationsNamesStringArrayList[1] = getString(R.string.notes_edit_medications_dialog_remove_all); for (int i = 0; i < medicationsJsonArrayLength; i++) { JSONObject medicationJsonObject = mPatientMedicationsJsonArray.getJSONObject(i); String name = medicationJsonObject.getString("name"); String manufacturer = medicationJsonObject.getString("manufacturer"); medicationsNamesArrayList.add(name); medicationsManufacturersArrayList.add(manufacturer); medicationsNamesStringArrayList[i + 2] = name; } String medicationsNames = ""; for (int n = 0; n < medicationsNamesArrayList.size(); n++) { medicationsNames += medicationsNamesArrayList.get(n) + ", "; } medicationsNames = medicationsNames.replaceAll(", $", ""); mPatientMedicationsTextView.setText(Html.fromHtml("<u>" + medicationsNames + "</u>")); mPatientMedicationsTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new MaterialDialog.Builder(mContext) .title(getString(R.string.notes_edit_medications_dialog_title)) .items(medicationsNamesStringArrayList) .itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) { if (i == 0) { String medicationsInteractions = ""; for (int n = 0; n < medicationsNamesArrayList.size(); n++) { medicationsInteractions += medicationsNamesArrayList.get(n) .split(" ")[0] + " "; } medicationsInteractions = medicationsInteractions.trim(); Intent intent = new Intent(mContext, InteractionsCardsActivity.class); intent.putExtra("search", medicationsInteractions); startActivity(intent); } else if (i == 1) { try { mPatientMedicationsJsonArray = new JSONArray("[]"); getMedications(); } catch (Exception e) { Log.e("NotesEditActivity", Log.getStackTraceString(e)); } } else { int position = i - 2; String medicationName = medicationsNamesArrayList.get(position); String medicationManufacturer = medicationsManufacturersArrayList .get(position); SQLiteDatabase sqLiteDatabase = new SlDataSQLiteHelper(mContext) .getReadableDatabase(); String[] queryColumns = { SlDataSQLiteHelper.MEDICATIONS_COLUMN_ID }; Cursor cursor = sqLiteDatabase.query( SlDataSQLiteHelper.TABLE_MEDICATIONS, queryColumns, SlDataSQLiteHelper.MEDICATIONS_COLUMN_NAME + " = " + mTools.sqe(medicationName) + " AND " + SlDataSQLiteHelper.MEDICATIONS_COLUMN_MANUFACTURER + " = " + mTools.sqe(medicationManufacturer), null, null, null, null); if (cursor.moveToFirst()) { long id = cursor.getLong(cursor.getColumnIndexOrThrow( SlDataSQLiteHelper.MEDICATIONS_COLUMN_ID)); Intent intent = new Intent(mContext, MedicationActivity.class); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mTools.getDefaultSharedPreferencesBoolean( "MEDICATION_MULTIPLE_DOCUMENTS")) intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT); } intent.putExtra("id", id); startActivity(intent); } cursor.close(); sqLiteDatabase.close(); } } }).itemColorRes(R.color.dark_blue).show(); } }); } } catch (Exception e) { Log.e("NotesEditActivity", Log.getStackTraceString(e)); } }
From source file:net.henryco.opalette.application.StartUpActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.startMenuAbout: { String appVersion = GodConfig.JSON_CONF.APP_NAME + " v" + GodConfig.JSON_CONF.APP_VERSION_NUMB + " " + GodConfig.JSON_CONF.APP_VERSION_TAG + "."; String about = "\n\n" + Utils.getSourceAssetsText(GodConfig.DEF_ABOUT_FILE, this); String mails = ""; for (String s : GodConfig.JSON_CONF.APP_DEV_MAILS) mails += "\n" + s; for (String s : GodConfig.JSON_CONF.APP_OTHER_MAILS) mails += "\n" + s; new OPallAlertDialog().title(getResources().getString(R.string.about)) .message(appVersion + about + mails).positive(getResources().getString(R.string.close)) .show(getSupportFragmentManager(), "About dialog"); return true; }/*from ww w .ja v a 2s . co m*/ case R.id.startMenuRate: { Uri uri = Uri.parse("market://details?id=" + getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK; if (Build.VERSION.SDK_INT >= 21) flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT; else flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; goToMarket.addFlags(flags); try { startActivity(goToMarket); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName()))); } return true; } case R.id.startMenuSettings: { Intent settingsIntent = new Intent(this, SettingsActivity.class); startActivity(settingsIntent); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:com.linkbubble.util.Util.java
static public Intent getSendIntent(String packageName, String className, String urlAsString) { // TODO: Retrieve the class name below from the app in case Twitter ever change it. Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.setClassName(packageName, className); if (packageName.equals(Constant.POCKET_PACKAGE_NAME)) { // Stop pocket spawning when links added intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } else {//from www . j av a 2 s . c om intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } intent.putExtra(Intent.EXTRA_TEXT, urlAsString); String title = MainApplication.sTitleHashMap != null ? MainApplication.sTitleHashMap.get(urlAsString) : null; if (title != null) { intent.putExtra(Intent.EXTRA_SUBJECT, title); } return intent; }
From source file:org.kiwix.kiwixmobile.KiwixMobileActivity.java
private void goToRateApp() { Intent goToMarket = new Intent(Intent.ACTION_VIEW, KIWIX_LOCAL_MARKET_URI); goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); try {//from w w w .j a v a2 s.c om startActivity(goToMarket); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, KIWIX_BROWSER_MARKET_URI)); } }
From source file:com.ubikod.capptain.android.sdk.reach.CapptainReachAgent.java
/** * Called when a notification is actioned. * @param content content associated to the notification. * @param launchIntent true to launch intent. *//*from ww w . j a v a 2 s . co m*/ void onNotificationActioned(CapptainReachContent content, boolean launchIntent) { /* Persist content state */ updateContentStatusTrue(content, NOTIFICATION_ACTIONED); /* Update state */ mState = State.SHOWING; mCurrentShownContentId = content.getLocalId(); /* Nothing more to do if intent must not be launched */ if (!launchIntent) return; /* Notification announcement */ if (content instanceof CapptainNotifAnnouncement) getNotifier(content).executeNotifAnnouncementAction((CapptainNotifAnnouncement) content); /* Start a content activity in its own task */ else { Intent intent = content.getIntent(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); mContext.startActivity(intent); } }
From source file:com.android.mail.compose.ComposeActivity.java
private static void launch(Context context, Account account, Message message, int action, String toAddress, String body, String quotedText, String subject, final ContentValues extraValues) { Intent intent = new Intent(ACTION_LAUNCH_COMPOSE); intent.setPackage(context.getPackageName()); intent.putExtra(EXTRA_FROM_EMAIL_TASK, true); intent.putExtra(EXTRA_ACTION, action); intent.putExtra(Utils.EXTRA_ACCOUNT, account); if (action == EDIT_DRAFT) { intent.putExtra(ORIGINAL_DRAFT_MESSAGE, message); } else {// w ww . j a va 2 s. c om intent.putExtra(EXTRA_IN_REFERENCE_TO_MESSAGE, message); } if (toAddress != null) { intent.putExtra(EXTRA_TO, toAddress); } if (body != null) { intent.putExtra(EXTRA_BODY, body); } if (quotedText != null) { intent.putExtra(EXTRA_QUOTED_TEXT, quotedText); } if (subject != null) { intent.putExtra(EXTRA_SUBJECT, subject); } if (extraValues != null) { LogUtils.d(LOG_TAG, "Launching with extraValues: %s", extraValues.toString()); intent.putExtra(EXTRA_VALUES, extraValues); } if (action == COMPOSE) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } else if (message != null) { intent.setData(Utils.normalizeUri(message.uri)); } context.startActivity(intent); }
From source file:io.github.hidroh.materialistic.AppUtils.java
@SuppressLint("InlinedApi") public static Intent multiWindowIntent(Activity activity, Intent intent) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode()) { intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); }//from w w w. jav a 2 s. com return intent; }
From source file:com.onesignal.OneSignal.java
private static boolean openURLFromNotification(Context context, JSONArray dataArray) { int jsonArraySize = dataArray.length(); boolean urlOpened = false; for (int i = 0; i < jsonArraySize; i++) { try {/*from w ww . j a va2 s . c om*/ JSONObject data = dataArray.getJSONObject(i); if (!data.has("custom")) continue; JSONObject customJSON = new JSONObject(data.getString("custom")); if (customJSON.has("u")) { String url = customJSON.getString("u"); if (!url.contains("://")) url = "http://" + url; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); urlOpened = true; } } catch (Throwable t) { Log(LOG_LEVEL.ERROR, "Error parsing JSON item " + i + "/" + jsonArraySize + " for launching a web URL.", t); } } return urlOpened; }
From source file:org.videolan.vlc.gui.video.VideoPlayerActivity.java
public static void start(Context context, String location, String title, int position, Boolean dontParse, Boolean fromStart, Boolean useStun) { //VideoPlayerActivity.cameraId=cameraid; if (ActivityDevice.current_camID != -1) cameraId = ActivityDevice.current_camID; else// w w w . j a v a 2 s . co m cameraId = ActivityShiPin.current_camID; Intent intent = new Intent(context, VideoPlayerActivity.class); intent.setAction(VideoPlayerActivity.PLAY_FROM_VIDEOGRID); intent.putExtra("itemLocation", location); intent.putExtra("itemTitle", title); intent.putExtra("dontParse", dontParse); intent.putExtra("fromStart", fromStart); intent.putExtra("useStun", useStun); intent.putExtra("itemPosition", position); if (dontParse) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); else { // Stop the currently running audio AudioServiceController asc = AudioServiceController.getInstance(); asc.stop(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } context.startActivity(intent); }
From source file:com.apptentive.android.sdk.ApptentiveInternal.java
public void showAboutInternal(Context context, boolean showBrandingBand) { Intent intent = new Intent(); intent.setClass(context, ApptentiveViewActivity.class); intent.putExtra(Constants.FragmentConfigKeys.TYPE, Constants.FragmentTypes.ABOUT); intent.putExtra(Constants.FragmentConfigKeys.EXTRA, showBrandingBand); if (!(context instanceof Activity)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); }//from w w w . java 2s. c o m context.startActivity(intent); }