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.krayzk9s.imgurholo.tools.ImageUtils.java
public static void shareImage(Fragment fragment, JSONParcelable imageData) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); try {//from w ww . j a v a 2s. c o m intent.putExtra(Intent.EXTRA_TEXT, imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK)); } catch (JSONException e) { Log.e("Error!", "bad link to share"); } fragment.startActivity(intent); }
From source file:com.android.mail.browse.MessageAttachmentBar.java
@Override public void viewAttachment() { if (mAttachment.contentUri == null) { LogUtils.e(LOG_TAG, "viewAttachment with null content uri"); return;//w w w . jav a2 s .c o m } Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); final String contentType = mAttachment.getContentType(); Utils.setIntentDataAndTypeAndNormalize(intent, mAttachment.contentUri, contentType); // For EML files, we want to open our dedicated // viewer rather than let any activity open it. if (MimeType.isEmlMimeType(contentType)) { intent.setPackage(getContext().getPackageName()); intent.putExtra(AccountFeedbackActivity.EXTRA_ACCOUNT_URI, mAccount != null ? mAccount.uri : null); } try { getContext().startActivity(intent); } catch (ActivityNotFoundException e) { // couldn't find activity for View intent LogUtils.e(LOG_TAG, e, "Couldn't find Activity for intent"); } }
From source file:com.orange.ocara.ui.activity.ListAuditActivity.java
@Receiver(actions = AuditExportService.EXPORT_SUCCESS, local = true, registerAt = Receiver.RegisterAt.OnResumeOnPause) @UiThread(propagation = UiThread.Propagation.REUSE) void onExportAuditDone(@Receiver.Extra String path) { setLoading(false);//from w ww.jav a 2 s .com exportFile = new File(path); switch (exportAction) { case EXPORT_ACTION_SHARE: { // create an intent, so the user can choose which application he/she wants to use to share this file final Intent intent = ShareCompat.IntentBuilder.from(this) .setType(MimeTypeMap.getSingleton() .getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(path))) .setStream(FileProvider.getUriForFile(this, "com.orange.ocara", exportFile)) .setChooserTitle("How do you want to share?").createChooserIntent() .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(intent); break; } case EXPORT_ACTION_SAVE: { createNewDocument(path); break; } } }
From source file:com.streaming.sweetplayer.PlayerActivity.java
private Intent getDefaultIntent() { String urlToShare = Config.DOMAIN + sSongUrl; String sharingText = mActivity.getString(R.string.sharing_text) + " " + urlToShare + " " + mActivity.getString(R.string.sharing_android_app) + " " + Config.GOOGLE_PLAY_LINK; Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, sSongName); sharingIntent.putExtra(Intent.EXTRA_TEXT, sharingText); return sharingIntent; }
From source file:ua.org.gdg.devfest.iosched.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *///from www . j av a2s. c om private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, roomName, mBuffer, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } // Compile list of links (submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews(); final Context context = mRootView.getContext(); List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>(); // Add session feedback link if (getResources().getBoolean(R.bool.has_feedback_enabled)) { links.add(new Pair<Integer, Intent>(R.string.session_feedback_submitlink, new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class))); } for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Intent> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); try { startActivity(link.second); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } // Show past/present/future and livestream status for this block. UIUtils.updateTimeBlockUI(context, mSessionBlockStart, mSessionBlockEnd, null, mSubtitle, subtitle); LOGD("Tracker", "Session: " + mTitleString); }
From source file:de.grobox.liberario.utils.TransportrUtils.java
static public void share(Context context, Trip trip) { //noinspection deprecation Intent sendIntent = new Intent().setAction(Intent.ACTION_SEND) .putExtra(Intent.EXTRA_SUBJECT, tripToSubject(context, trip, true)) .putExtra(Intent.EXTRA_TEXT, tripToString(context, trip)).setType("text/plain") .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); context.startActivity(/*from w w w.j av a 2 s .c o m*/ Intent.createChooser(sendIntent, context.getResources().getText(R.string.share_trip_via))); }
From source file:com.android.deskclock.stopwatch.StopwatchFragment.java
/** * Send stopwatch time and lap times to an external sharing application. *//* w w w . jav a 2 s . co m*/ private void doShare() { final String[] subjects = getResources().getStringArray(R.array.sw_share_strings); final String subject = subjects[(int) (Math.random() * subjects.length)]; final String text = mLapsAdapter.getShareText(); @SuppressLint("InlinedApi") @SuppressWarnings("deprecation") final Intent shareIntent = new Intent(Intent.ACTION_SEND) .addFlags(Utils.isLOrLater() ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, text).setType("text/plain"); final Context context = getActivity(); final String title = context.getString(R.string.sw_share_button); final Intent shareChooserIntent = Intent.createChooser(shareIntent, title); try { context.startActivity(shareChooserIntent); } catch (ActivityNotFoundException anfe) { LogUtils.e("No compatible receiver is found"); } }
From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *///from w ww .j a v a2s . c om private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mType = cursor.getString(SessionsQuery.TYPE); mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, roomName, mBuffer, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } // Compile list of links (submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews(); final Context context = mRootView.getContext(); List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>(); // Add session feedback link if (getResources().getBoolean(R.bool.has_session_feedback_enabled)) { links.add(new Pair<Integer, Intent>(R.string.session_feedback_submitlink, new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class))); } for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Intent> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); try { startActivity(link.second); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } // Show past/present/future and livestream status for this block. UIUtils.updateTimeBlockUI(context, mSessionBlockStart, mSessionBlockEnd, null, mSubtitle, subtitle); LOGD("Tracker", "Session: " + mTitleString); }
From source file:cis350.blanket.IntentIntegrator.java
/** * Create an scan intent with the specified options. * * @return the intent// ww w.j a v a 2 s.co m */ public Intent createScanIntent() { Intent intentScan = new Intent(activity, getCaptureActivity()); intentScan.setAction("com.google.zxing.client.android.SCAN"); // check which types of codes to scan for if (desiredBarcodeFormats != null) { // set the desired barcode types StringBuilder joinedByComma = new StringBuilder(); for (String format : desiredBarcodeFormats) { if (joinedByComma.length() > 0) { joinedByComma.append(','); } joinedByComma.append(format); } intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString()); } intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intentScan); return intentScan; }
From source file:com.google.zxing.client.android.CaptureActivity.java
private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) { if (source == IntentSource.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); JSONObject jsonObject = new JSONObject(); try {//from ww w. j a v a 2s. c o m jsonObject.put("code", rawResult.toString()); jsonObject.put("result", rawResult.getText()); jsonObject.put("type", rawResult.getBarcodeFormat()); Map<ResultMetadataType, Object> data = new Hashtable<ResultMetadataType, Object>(); @SuppressWarnings("rawtypes") Iterator iterator = data.keySet().iterator(); while (iterator.hasNext()) { final ResultMetadataType key = (ResultMetadataType) iterator.next(); jsonObject.put(key.toString(), data.get(key).toString()); } jsonObject.put("timestamp", rawResult.getTimestamp()); } catch (JSONException e) { e.printStackTrace(); } intent.putExtra(EUExCallback.F_JK_CODE, rawResult.toString()); intent.putExtra(EUExCallback.F_JK_TYPE, rawResult.getBarcodeFormat().toString()); sendReplyMessage(EUExUtil.getResIdID("return_scan_result"), intent, 0); } }