List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET.
Click Source Link
From source file:com.irccloud.android.activity.ImageViewerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_imageviewer, menu); if (getIntent() != null && getIntent().getDataString() != null) { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse( getIntent().getDataString().replace(getResources().getString(R.string.IMAGE_SCHEME), "http"))); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, getIntent().getDataString().replace(getResources().getString(R.string.IMAGE_SCHEME), "http")); intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName()); intent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY, getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK); MenuItem shareItem = menu.findItem(R.id.action_share); ShareActionProviderHax share = (ShareActionProviderHax) MenuItemCompat.getActionProvider(shareItem); share.onShareActionProviderSubVisibilityChangedListener = this; share.setShareIntent(intent);/* w ww . ja v a 2s . c om*/ } return true; }
From source file:com.irccloud.android.activity.PastebinViewerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish();/*from w w w . j ava 2s . c o m*/ if (getWindowManager().getDefaultDisplay().getWidth() < TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 800, getResources().getDisplayMetrics()) || isMultiWindow()) overridePendingTransition(R.anim.fade_in, R.anim.slide_out_right); return true; } else if (item.getItemId() == R.id.delete) { if (Uri.parse(url).getQueryParameter("own_paste").equals("1")) { AlertDialog.Builder builder = new AlertDialog.Builder(PastebinViewerActivity.this); builder.setTitle("Delete Snippet"); builder.setMessage("Are you sure you want to delete this snippet?"); builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { NetworkConnection.getInstance().delete_paste(Uri.parse(url).getQueryParameter("id")); finish(); Toast.makeText(PastebinViewerActivity.this, "Snippet deleted", Toast.LENGTH_SHORT).show(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); } }); AlertDialog d = builder.create(); d.setOwnerActivity(PastebinViewerActivity.this); d.show(); } } else if (item.getItemId() == R.id.action_linenumbers) { item.setChecked(!item.isChecked()); mWebView.loadUrl("javascript:window.PASTEVIEW.doToggleLines()"); } else if (item.getItemId() == R.id.action_browser) { if (!PreferenceManager .getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext()) .getBoolean("browser", false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); builder.setToolbarColor(ColorScheme.getInstance().navBarColor); builder.addDefaultShareMenuItem(); builder.addMenuItem("Copy URL", PendingIntent.getBroadcast(this, 0, new Intent(this, ChromeCopyLinkBroadcastReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT)); CustomTabsIntent intent = builder.build(); intent.intent.setData(Uri.parse(url.contains("?") ? url.substring(0, url.indexOf("?")) : url)); if (Build.VERSION.SDK_INT >= 22) intent.intent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + getPackageName())); if (Build.VERSION.SDK_INT >= 16 && intent.startAnimationBundle != null) { startActivity(intent.intent, intent.startAnimationBundle); } else { startActivity(intent.intent); } } else { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url.contains("?") ? url.substring(0, url.indexOf("?")) : url)); startActivity(intent); } finish(); return true; } else if (item.getItemId() == R.id.action_copy) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( CLIPBOARD_SERVICE); if (url.contains("?")) clipboard.setText(url.substring(0, url.indexOf("?"))); else clipboard.setText(url); } else { @SuppressLint("ServiceCast") android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( CLIPBOARD_SERVICE); android.content.ClipData clip; if (url.contains("?")) clip = android.content.ClipData.newRawUri("IRCCloud Snippet URL", Uri.parse(url.substring(0, url.indexOf("?")))); else clip = android.content.ClipData.newRawUri("IRCCloud Snippet URL", Uri.parse(url)); clipboard.setPrimaryClip(clip); } Toast.makeText(PastebinViewerActivity.this, "Link copied to clipboard", Toast.LENGTH_SHORT).show(); } else if (item.getItemId() == R.id.action_share) { if (getIntent() != null && getIntent().getDataString() != null) { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse(url)); intent.setType("text/plain"); if (url.contains("?")) intent.putExtra(Intent.EXTRA_TEXT, url.substring(0, url.indexOf("?"))); else intent.putExtra(Intent.EXTRA_TEXT, url); intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName()); intent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY, getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, "Share Snippet")); Answers.getInstance().logShare(new ShareEvent().putContentType("Pastebin")); } } else if (item.getItemId() == R.id.action_edit) { mSpinner.setVisibility(View.VISIBLE); Intent i = new Intent(this, PastebinEditorActivity.class); i.putExtra("paste_id", Uri.parse(url).getQueryParameter("id")); startActivityForResult(i, 1); } return super.onOptionsItemSelected(item); }
From source file:fr.mixit.android.ui.fragments.SessionDetailsFragment.java
protected Intent createShareIntent() { final Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_session_subject)); shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_session_text, mTitleStr, createLinkFromTitle(String.valueOf(mSessionId), mTitleStr))); // shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_session_text, mTitleStr, "http://www.mix-it.fr/sessions")); return shareIntent; }
From source file:com.nutomic.syncthingandroid.util.BarcodeIntentIntegrator.java
/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise *//*from w w w . j a v a2 s .co m*/ @TargetApi(11) public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment != null) { fragment.startActivity(intent); } else if (fragmentV4 != null) { fragmentV4.startActivity(intent); } else { activity.startActivity(intent); } return null; }
From source file:com.google.zxing.integration.android.SupportIntentIntegrator.java
/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise *///from www .j a v a 2 s. co m public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment != null) { fragment.startActivity(intent); } else if (fragmentV4 != null) { fragmentV4.startActivity(intent); } else { activity.startActivity(intent); } return null; }
From source file:com.battlelancer.seriesguide.util.Utils.java
/** * Tries to launch a web browser loading the given URL. Sets a flag to exit the browser if * coming back to the app.//from ww w. ja v a 2 s. c o m */ public static void launchWebsite(Context context, String url, String logTag, String logItem) { if (context == null || TextUtils.isEmpty(url)) { return; } Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // try to launch web browser Utils.tryStartActivity(context, intent, true); Utils.trackAction(context, logTag, logItem); }
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 w w . j a v a 2 s.com*/ 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:app.axe.imooc.zxing.app.CaptureActivity.java
private void handleDecodeExternally(Result rawResult, Bitmap barcode) { viewfinderView.drawResultBitmap(barcode); // Since this message will only be shown for a second, just tell the // user what kind of // barcode was found (e.g. contact info) rather than the full contents, // which they won't // have time to read. if (source == Source.NATIVE_APP_INTENT) { // Hand back whatever action they requested - this can be changed to // Intents.Scan.ACTION when // the deprecated intent is retired. Intent intent = new Intent(getIntent().getAction()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intents.Scan.RESULT, rawResult.toString()); intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString()); Message message = Message.obtain(handler, R.id.return_scan_result); message.obj = intent;/*from w ww. ja va 2 s . c om*/ handler.sendMessageDelayed(message, INTENT_RESULT_DURATION); } else if (source == Source.PRODUCT_SEARCH_LINK) { // Reformulate the URL which triggered us into a query, so that the // request goes to the same // TLD as the scan URL. Message message = Message.obtain(handler, R.id.launch_product_query); // message.obj = sourceUrl.substring(0, end) + "?q=" + // resultHandler.getDisplayContents().toString() // + "&source=zxing"; handler.sendMessageDelayed(message, INTENT_RESULT_DURATION); } else if (source == Source.ZXING_LINK) { // Replace each occurrence of RETURN_CODE_PLACEHOLDER in the // returnUrlTemplate // with the scanned code. This allows both queries and REST-style // URLs to work. Message message = Message.obtain(handler, R.id.launch_product_query); // message.obj = returnUrlTemplate.replace(RETURN_CODE_PLACEHOLDER, // resultHandler.getDisplayContents() // .toString()); handler.sendMessageDelayed(message, INTENT_RESULT_DURATION); } }
From source file:com.android.mms.ui.ConversationList.java
public static Intent createAddContactIntent(String address) { // address must be a single recipient Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); intent.setType(Contacts.CONTENT_ITEM_TYPE); if (Mms.isEmailAddress(address)) { intent.putExtra(ContactsContract.Intents.Insert.EMAIL, address); } else {/*w w w . j a va 2s . co m*/ intent.putExtra(ContactsContract.Intents.Insert.PHONE, address); intent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE); } intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); return intent; }