List of usage examples for android.content Intent FLAG_ACTIVITY_NEW_DOCUMENT
int FLAG_ACTIVITY_NEW_DOCUMENT
To view the source code for android.content Intent FLAG_ACTIVITY_NEW_DOCUMENT.
Click Source Link
From source file:com.amaze.filemanager.utils.files.FileUtils.java
private static void applyNewDocFlag(Intent i) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { i.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); } else {//w ww.j a va 2s .c o m i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME | Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS); } }
From source file:com.google.samples.apps.iosched.session.SessionDetailModel.java
private int getFlagForUrlLink() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; } else {//from w ww . j a v a2s . c o m return Intent.FLAG_ACTIVITY_NEW_DOCUMENT; } }
From source file:arun.com.chromer.browsing.customtabs.CustomTabs.java
private void prepareChromerOptions() { final Intent moreMenuActivity = new Intent(activity, ChromerOptionsActivity.class); moreMenuActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); moreMenuActivity.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { moreMenuActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); }/*from www . ja v a 2 s .co m*/ moreMenuActivity.putExtra(EXTRA_KEY_ORIGINAL_URL, url); final PendingIntent moreMenuPending = PendingIntent.getActivity(activity, 0, moreMenuActivity, FLAG_UPDATE_CURRENT); builder.addMenuItem(activity.getString(R.string.chromer_options), moreMenuPending); }
From source file:p1.nd.khan.jubair.mohammadd.popularmovies.adapter.MovieDetailsAdapter.java
private void shareTrailer(String tKey, String tName) { Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("text/plain"); share.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); share.putExtra(Intent.EXTRA_SUBJECT, tName); share.putExtra(Intent.EXTRA_TEXT, MessageFormat.format(mContext.getString(R.string.youtube_url), tKey)); mContext.startActivity(Intent.createChooser(share, "Share Movie Trailer")); }
From source file:org.puder.trs80.MainActivity.java
private void showRating() { Uri uri = Uri.parse("market://details?id=" + getPackageName()); Intent playMarketIntent = new Intent(Intent.ACTION_VIEW, uri); playMarketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); try {/*from www . j a v a 2 s . com*/ startActivity(playMarketIntent); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName()))); } }
From source file:net.olejon.mdapp.NotesEditActivity.java
private void getMedications() { try {/*from w w w . j av a2s . 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 w ww . j a va2 s.c o 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.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 {//from w ww .j ava 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:com.tct.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) { //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S if (message != null && message.bodyHtml != null && message.bodyHtml.length() > 1024 * 5) { message.bodyHtml = ""; LogUtils.d("Email", "test---launch---bodyHtml set to empty"); }//ww w . j ava 2s. c o m if (message != null && message.bodyText != null && message.bodyText.length() > 1024 * 5) { message.bodyText = ""; LogUtils.d("Email", "test---launch---bodyText set to empty"); } //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_E //Note: intent can not take too much extra data, so not take these two string in extra data. if (message != null) { message.bodyHtmlLinkify = ""; message.bodyTextLinkify = ""; } 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 { intent.putExtra(EXTRA_IN_REFERENCE_TO_MESSAGE, message); } if (message != null) { LogUtils.d("Email", String.format("test---launch---action=%d messageId=%d conversationUri=%s uri=%s subject=%s", action, message.id, message.conversationUri, message.uri, message.subject)); } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_S // if(message != null && message.bodyHtml != null && message.bodyHtml.length() > 1024*10){ // message.bodyHtml = ""; // Log.d("Email","test---launch---bodyHtml set to empty"); // } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_E 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) { //TS: jin.dong 2015-10-19 EMAIL BUGFIX_1100033 ADD_S if (message.uri == null) { LogUtils.e(LOG_TAG, "what ? message's uri is null? want launch ComposeActivity ? do nothing is the right thing!!!"); return; } //TS: jin.dong 2015-10-19 EMAIL BUGFIX_1100033 ADD_E //TS: yanhua.chen 2016-03-31 EMAIL BUGFIX_1877378 ADD_S intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); //TS: yanhua.chen 2016-03-31 EMAIL BUGFIX_1877378 ADD_E intent.setData(Utils.normalizeUri(message.uri)); } // TS: xiaolin.li 2015-01-29 EMAIL BUGFIX-917401 ADD_S //context.startActivity(intent); try { context.startActivity(intent); } catch (Exception e) { LogUtils.e(LOG_TAG, "Launch compose activity err."); } // TS: xiaolin.li 2015-01-29 EMAIL BUGFIX-917401 ADD_E }