List of usage examples for android.content Intent ACTION_SEND
String ACTION_SEND
To view the source code for android.content Intent ACTION_SEND.
Click Source Link
From source file:com.android.mail.compose.ComposeActivity.java
private void finishCreate() { final Bundle savedState = mInnerSavedState; findViews();//ww w . jav a 2 s. c om final Intent intent = getIntent(); final Message message; final ArrayList<AttachmentPreview> previews; mShowQuotedText = false; final CharSequence quotedText; int action; // Check for any of the possibly supplied accounts.; final Account account; if (hadSavedInstanceStateMessage(savedState)) { action = savedState.getInt(EXTRA_ACTION, COMPOSE); account = savedState.getParcelable(Utils.EXTRA_ACCOUNT); message = savedState.getParcelable(EXTRA_MESSAGE); previews = savedState.getParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = savedState.getParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE); quotedText = savedState.getCharSequence(EXTRA_QUOTED_TEXT); mExtraValues = savedState.getParcelable(EXTRA_VALUES); // Get the draft id from the request id if there is one. if (savedState.containsKey(EXTRA_REQUEST_ID)) { final int requestId = savedState.getInt(EXTRA_REQUEST_ID); if (sRequestMessageIdMap.containsKey(requestId)) { synchronized (mDraftLock) { mDraftId = sRequestMessageIdMap.get(requestId); } } } } else { account = obtainAccount(intent); action = intent.getIntExtra(EXTRA_ACTION, COMPOSE); // Initialize the message from the message in the intent message = intent.getParcelableExtra(ORIGINAL_DRAFT_MESSAGE); previews = intent.getParcelableArrayListExtra(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE); mRefMessageUri = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE_URI); quotedText = null; if (Analytics.isLoggable()) { if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().sendEvent("notification_action", "compose", getActionString(action), 0); } } } mAttachmentsView.setAttachmentPreviews(previews); setAccount(account); if (mAccount == null) { return; } initRecipients(); // Clear the notification and mark the conversation as seen, if necessary final Folder notificationFolder = intent.getParcelableExtra(EXTRA_NOTIFICATION_FOLDER); if (notificationFolder != null) { final Uri conversationUri = intent.getParcelableExtra(EXTRA_NOTIFICATION_CONVERSATION); Intent actionIntent; if (conversationUri != null) { actionIntent = new Intent(MailIntentService.ACTION_RESEND_NOTIFICATIONS_WEAR); actionIntent.putExtra(Utils.EXTRA_CONVERSATION, conversationUri); } else { actionIntent = new Intent(MailIntentService.ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS); actionIntent.setData(Utils.appendVersionQueryParameter(this, notificationFolder.folderUri.fullUri)); } actionIntent.setPackage(getPackageName()); actionIntent.putExtra(Utils.EXTRA_ACCOUNT, account); actionIntent.putExtra(Utils.EXTRA_FOLDER, notificationFolder); startService(actionIntent); } if (intent.getBooleanExtra(EXTRA_FROM_EMAIL_TASK, false)) { mLaunchedFromEmail = true; } else if (Intent.ACTION_SEND.equals(intent.getAction())) { final Uri dataUri = intent.getData(); if (dataUri != null) { final String dataScheme = intent.getData().getScheme(); final String accountScheme = mAccount.composeIntentUri.getScheme(); mLaunchedFromEmail = TextUtils.equals(dataScheme, accountScheme); } } if (mRefMessageUri != null) { mShowQuotedText = true; mComposeMode = action; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); String wearReply = null; if (remoteInput != null) { LogUtils.d(LOG_TAG, "Got remote input from new api"); CharSequence input = remoteInput.getCharSequence(NotificationActionUtils.WEAR_REPLY_INPUT); if (input != null) { wearReply = input.toString(); } } else { // TODO: remove after legacy code has been removed. LogUtils.d(LOG_TAG, "No remote input from new api, falling back to compatibility mode"); ClipData clipData = intent.getClipData(); if (clipData != null && LEGACY_WEAR_EXTRA.equals(clipData.getDescription().getLabel())) { Bundle extras = clipData.getItemAt(0).getIntent().getExtras(); if (extras != null) { wearReply = extras.getString(NotificationActionUtils.WEAR_REPLY_INPUT); } } } if (!TextUtils.isEmpty(wearReply)) { createWearReplyTask(this, mRefMessageUri, UIProvider.MESSAGE_PROJECTION, mComposeMode, wearReply).execute(); finish(); return; } else { LogUtils.w(LOG_TAG, "remote input string is null"); } } getLoaderManager().initLoader(INIT_DRAFT_USING_REFERENCE_MESSAGE, null, this); return; } else if (message != null && action != EDIT_DRAFT) { initFromDraftMessage(message); initQuotedTextFromRefMessage(mRefMessage, action); mShowQuotedText = message.appendRefMessageContent; // if we should be showing quoted text but mRefMessage is null // and we have some quotedText, display that if (mShowQuotedText && mRefMessage == null) { if (quotedText != null) { initQuotedText(quotedText, false /* shouldQuoteText */); } else if (mExtraValues != null) { initExtraValues(mExtraValues); return; } } } else if (action == EDIT_DRAFT) { if (message == null) { throw new IllegalStateException("Message must not be null to edit draft"); } initFromDraftMessage(message); // Update the action to the draft type of the previous draft switch (message.draftType) { case UIProvider.DraftType.REPLY: action = REPLY; break; case UIProvider.DraftType.REPLY_ALL: action = REPLY_ALL; break; case UIProvider.DraftType.FORWARD: action = FORWARD; break; case UIProvider.DraftType.COMPOSE: default: action = COMPOSE; break; } LogUtils.d(LOG_TAG, "Previous draft had action type: %d", action); mShowQuotedText = message.appendRefMessageContent; if (message.refMessageUri != null) { // If we're editing an existing draft that was in reference to an existing message, // still need to load that original message since we might need to refer to the // original sender and recipients if user switches "reply <-> reply-all". mRefMessageUri = message.refMessageUri; mComposeMode = action; getLoaderManager().initLoader(REFERENCE_MESSAGE_LOADER, null, this); return; } } else if ((action == REPLY || action == REPLY_ALL || action == FORWARD)) { if (mRefMessage != null) { initFromRefMessage(action); mShowQuotedText = true; } } else { if (initFromExtras(intent)) { return; } } mComposeMode = action; finishSetup(action, intent, savedState); }
From source file:com.ryan.ryanreader.fragments.CommentListingFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (info.position <= 0) return false; final Action action = Action.values()[item.getItemId()]; final RedditPreparedComment comment = (RedditPreparedComment) lv.getAdapter().getItem(info.position); switch (action) { case UPVOTE://w w w . java 2 s . co m comment.action(getSupportActivity(), RedditAPI.RedditAction.UPVOTE); break; case DOWNVOTE: comment.action(getSupportActivity(), RedditAPI.RedditAction.DOWNVOTE); break; case UNVOTE: comment.action(getSupportActivity(), RedditAPI.RedditAction.UNVOTE); break; case REPORT: new AlertDialog.Builder(getSupportActivity()).setTitle(R.string.action_report) .setMessage(R.string.action_report_sure) .setPositiveButton(R.string.action_report, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { comment.action(getSupportActivity(), RedditAPI.RedditAction.REPORT); // TODO update the view to show the result } }).setNegativeButton(R.string.dialog_cancel, null).show(); break; case REPLY: { final Intent intent = new Intent(getSupportActivity(), CommentReplyActivity.class); intent.putExtra("parentIdAndType", comment.idAndType); startActivity(intent); break; } case EDIT: { final Intent intent = new Intent(getSupportActivity(), CommentEditActivity.class); intent.putExtra("commentIdAndType", comment.idAndType); intent.putExtra("commentText", comment.src.body); startActivity(intent); break; } case COMMENT_LINKS: final HashSet<String> linksInComment = comment.computeAllLinks(); if (linksInComment.isEmpty()) { General.quickToast(getSupportActivity(), R.string.error_toast_no_urls_in_comment); } else { final String[] linksArr = linksInComment.toArray(new String[linksInComment.size()]); final AlertDialog.Builder builder = new AlertDialog.Builder(getSupportActivity()); builder.setItems(linksArr, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { LinkHandler.onLinkClicked(getSupportActivity(), linksArr[which], false); dialog.dismiss(); } }); final AlertDialog alert = builder.create(); alert.setTitle(R.string.action_comment_links); alert.setCanceledOnTouchOutside(true); alert.show(); } break; case SHARE: final Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("text/plain"); mailer.putExtra(Intent.EXTRA_SUBJECT, "Comment by " + comment.src.author + " on Reddit"); // TODO this currently just dumps the markdown mailer.putExtra(Intent.EXTRA_TEXT, StringEscapeUtils.unescapeHtml4(comment.src.body)); startActivityForResult(Intent.createChooser(mailer, context.getString(R.string.action_share)), 1); break; case COPY: ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); // TODO this currently just dumps the markdown manager.setText(StringEscapeUtils.unescapeHtml4(comment.src.body)); break; case COLLAPSE: if (comment.getBoundView() != null) handleCommentVisibilityToggle(comment.getBoundView()); break; case USER_PROFILE: UserProfileDialog.newInstance(comment.src.author).show(getSupportActivity()); break; case PROPERTIES: CommentPropertiesDialog.newInstance(comment.src).show(getSupportActivity()); break; } return true; }
From source file:com.audiokernel.euphonyrmt.fragments.NowPlayingFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { final AlbumInfo albumInfo; boolean result = true; final int itemId = item.getItemId(); switch (item.getItemId()) { case POPUP_COVER_BLACKLIST: albumInfo = new AlbumInfo(mCurrentSong); CoverManager.getInstance().markWrongCover(albumInfo); downloadCover(albumInfo);// www .j ava2s . c om updateQueueCovers(albumInfo); break; case POPUP_COVER_SELECTIVE_CLEAN: albumInfo = new AlbumInfo(mCurrentSong); CoverManager.getInstance().clear(albumInfo); downloadCover(albumInfo); updateQueueCovers(albumInfo); break; case POPUP_CURRENT: scrollToNowPlaying(); break; case POPUP_SHARE: final Intent intent = new Intent(Intent.ACTION_SEND, null); intent.putExtra(Intent.EXTRA_TEXT, getShareString()); intent.setType("text/plain"); startActivity(intent); break; default: result = isSimpleLibraryItem(itemId); break; } return result; }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void emailLog(final CallbackContext callback, final String email) { cordova.getThreadPool().execute(new Runnable() { public void run() { String log = readLog(); if (log == null) { callback.error(500);/* w ww. j a v a2s . c om*/ return; } Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("message/rfc822"); mailer.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); mailer.putExtra(Intent.EXTRA_SUBJECT, "BackgroundGeolocation log"); try { JSONObject state = getState(); if (state.has("license")) { state.put("license", "<SECRET>"); } if (state.has("orderId")) { state.put("orderId", "<SECRET>"); } mailer.putExtra(Intent.EXTRA_TEXT, state.toString(4)); } catch (JSONException e) { Log.w(TAG, "- Failed to write state to email body"); e.printStackTrace(); } File file = new File(Environment.getExternalStorageDirectory(), "background-geolocation.log"); try { FileOutputStream stream = new FileOutputStream(file); try { stream.write(log.getBytes()); stream.close(); mailer.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); file.deleteOnExit(); } catch (IOException e) { e.printStackTrace(); } } catch (FileNotFoundException e) { Log.i(TAG, "FileNotFound"); e.printStackTrace(); } try { cordova.getActivity() .startActivityForResult(Intent.createChooser(mailer, "Send log: " + email + "..."), 1); callback.success(); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(cordova.getActivity(), "There are no email clients installed.", Toast.LENGTH_SHORT).show(); callback.error("There are no email clients installed"); } } }); }
From source file:at.alladin.rmbt.android.adapter.result.RMBTResultPagerAdapter.java
/** * //from w w w . j a v a 2 s. c om */ public void startShareResultsIntent() { try { JSONObject resultListItem = testResult.getJSONObject(0); final String shareText = resultListItem.getString("share_text"); final String shareSubject = resultListItem.getString("share_subject"); final Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, shareText); sendIntent.putExtra(Intent.EXTRA_SUBJECT, shareSubject); sendIntent.setType("text/plain"); activity.startActivity(Intent.createChooser(sendIntent, null)); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
/** * Parses the intent// w ww . jav a 2s . c o m */ private void parseIntent(Intent intent) { final String action = intent.getAction(); final String type = intent.getType(); if (Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action) || Intent.ACTION_PICK.equals(action) && type != null) { // Post event //newFileToOpen(new File(intent // .getData().getPath()), ""); Uri uri = intent.getData(); GreatUri newUri = new GreatUri(uri, AccessStorageApi.getPath(this, uri), AccessStorageApi.getName(this, uri)); newFileToOpen(newUri, ""); } else if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { newFileToOpen(new GreatUri(Uri.EMPTY, "", ""), intent.getStringExtra(Intent.EXTRA_TEXT)); } } }
From source file:com.justone.android.main.MainActivity.java
public void shareOnClick(View view) { String shareTitle = ""; String shareContent = " "; if (tabs.getCurrentTabTag() == "home tab") { shareTitle = "home tab"; shareContent = shareContent + ((TextView) this.findViewById(R.id.fPage_tView)).getText().toString() + ((TextView) this.findViewById(R.id.imageBelow_tView)).getText().toString() + "() " + ((TextView) this.findViewById(R.id.home_share_url)).getText().toString(); } else if (tabs.getCurrentTabTag() == "QA Tab") { shareTitle = "QA Tab"; shareContent = shareContent + ((TextView) this.findViewById(R.id.question_content)).getText().toString() + " - () " + ((TextView) this.findViewById(R.id.qa_share_url)).getText().toString(); } else if (tabs.getCurrentTabTag() == "list tab") { shareTitle = "list tab"; shareContent = shareContent + "" + ((TextView) this.findViewById(R.id.one_content_title)).getText().toString() + " by " + ((TextView) this.findViewById(R.id.one_content_author)).getText().toString() + "- () " + ((TextView) this.findViewById(R.id.list_share_url)).getText().toString(); }//from w w w . ja v a 2 s.c om Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); // intent.setPackage("com.sina.weibo"); intent.putExtra(Intent.EXTRA_SUBJECT, ""); //intent.putExtra(Intent.EXTRA_TEXT, shareTitle+" VOL.516 () http://caodan.org/516-photo.html "); intent.putExtra(Intent.EXTRA_TEXT, shareContent); intent.putExtra(Intent.EXTRA_TITLE, shareTitle); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, "")); }
From source file:it.feio.android.omninotes.DetailFragment.java
/** * Performs an action when long-click option is selected * @param attachmentPosition/*w w w. ja v a 2s. c o m*/ * @param i item index */ private void performAttachmentAction(int attachmentPosition, int i) { switch (getResources().getStringArray(R.array.attachments_actions_values)[i]) { case "share": Intent shareIntent = new Intent(Intent.ACTION_SEND); Attachment attachment = mAttachmentAdapter.getItem(attachmentPosition); shareIntent.setType(StorageHelper.getMimeType(OmniNotes.getAppContext(), attachment.getUri())); shareIntent.putExtra(Intent.EXTRA_STREAM, attachment.getUri()); if (IntentChecker.isAvailable(OmniNotes.getAppContext(), shareIntent, null)) { startActivity(shareIntent); } else { mainActivity.showMessage(R.string.feature_not_available_on_this_device, ONStyle.WARN); } break; case "delete": removeAttachment(attachmentPosition); mAttachmentAdapter.notifyDataSetChanged(); mGridView.autoresize(); break; case "delete all": new MaterialDialog.Builder(mainActivity).title(R.string.delete_all_attachments) .positiveText(R.string.confirm) .onPositive((materialDialog, dialogAction) -> removeAllAttachments()).build().show(); break; case "edit": takeSketch(mAttachmentAdapter.getItem(attachmentPosition)); break; default: Log.w(Constants.TAG, "No action available"); } }
From source file:com.piusvelte.taplock.client.core.TapLockSettings.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.button_add_device) addDevice();/*from w ww. j av a 2s . co m*/ else if (itemId == R.id.button_about) { mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle(R.string.button_about) .setMessage(R.string.about) .setNeutralButton(R.string.button_getserver, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickinstaller) .setItems(R.array.installer_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); final String installer_file = getResources() .getStringArray(R.array.installer_values)[which]; mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickdownloader) .setItems(R.array.download_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); String action = getResources().getStringArray( R.array.download_values)[which]; if (ACTION_DOWNLOAD_SDCARD.equals(action) && copyFileToSDCard(installer_file)) Toast.makeText(TapLockSettings.this, "Done!", Toast.LENGTH_SHORT).show(); else if (ACTION_DOWNLOAD_EMAIL.equals(action) && copyFileToSDCard(installer_file)) { Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND); emailIntent.setType( "application/java-archive"); emailIntent.putExtra(Intent.EXTRA_TEXT, getString( R.string.email_instructions)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + Environment .getExternalStorageDirectory() .getPath() + "/" + installer_file)); startActivity(Intent.createChooser( emailIntent, getString( R.string.button_getserver))); } } }) .create(); mDialog.show(); } }).create(); mDialog.show(); } }).setPositiveButton(R.string.button_license, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.button_license).setMessage(R.string.license).create(); mDialog.show(); } }).create(); mDialog.show(); } return super.onOptionsItemSelected(item); }
From source file:ca.uwaterloo.magic.goodhikes.MapsActivity.java
public void CaptureMapScreen() { GoogleMap.SnapshotReadyCallback callback = new GoogleMap.SnapshotReadyCallback() { Bitmap bitmap;/*from w w w . j a v a 2 s.c om*/ @Override public void onSnapshotReady(Bitmap snapshot) { // TODO Auto-generated method stub bitmap = snapshot; String path = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "route_screenshot", null); Uri uri_image = Uri.parse(path); // share intent Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_STREAM, uri_image); sendIntent.putExtra(Intent.EXTRA_TEXT, "My Route"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Hey! Check out my route on Goodhikes"); sendIntent.setType("image/*"); startActivity(Intent.createChooser(sendIntent, "Share to...")); } }; mMap.snapshot(callback); }