List of usage examples for android.content Intent EXTRA_SUBJECT
String EXTRA_SUBJECT
To view the source code for android.content Intent EXTRA_SUBJECT.
Click Source Link
From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java
private boolean sendEmail(String body, String subject, String userEmail) { userEmail = findAccount(userEmail);/* w w w . ja va 2 s.c o m*/ Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String aEmailList[] = { userEmail }; emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); emailIntent.setType("plain/text"); try { startActivity(emailIntent); return true; } catch (ActivityNotFoundException anf) { Log.i(PacoConstants.TAG, "No email client configured"); return false; } }
From source file:com.flipzu.flipzu.Player.java
private void shareFlipzu() { //create the intent Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); //set the type shareIntent.setType("text/plain"); //add a subject shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Check out this cool App"); //build the body of the message to be shared String shareMessage = "Flipzu, live audio broadcast from your Android phone: https://market.android.com/details?id=" + APP_PNAME;// w w w. jav a 2 s . c o m //add the message shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); //start the chooser for sharing startActivity(Intent.createChooser(shareIntent, getText(R.string.share_app))); }
From source file:com.aimfire.main.MainActivity.java
/** * share only to certain apps. code based on "http://stackoverflow.com/questions/ * 9730243/how-to-filter-specific-apps-for-action-send-intent-and-set-a-different- * text-for/18980872#18980872"//from w ww.j a va 2s.c o m * * "copy link" inspired by http://cketti.de/2016/06/15/share-url-to-clipboard/ * * in general, "deep linking" is supported by the apps below. Facebook, Wechat, * Telegram are exceptions. click on the link would bring users to the landing * page. * * Facebook doesn't take our EXTRA_TEXT so user will have to "copy link" first * then paste the link */ private void inviteFriend() { mFirebaseAnalytics.logEvent(MainConsts.FIREBASE_CUSTOM_EVENT_INVITE, null); Resources resources = getResources(); /* * construct link */ String appLink = resources.getString(R.string.app_store_link); /* * message subject and text */ String emailSubject, emailText, twitterText; emailSubject = resources.getString(R.string.emailSubjectInviteFriend); emailText = resources.getString(R.string.emailBodyInviteFriend) + appLink; twitterText = resources.getString(R.string.emailBodyInviteFriend) + appLink + ", " + resources.getString(R.string.app_hashtag); Intent emailIntent = new Intent(); emailIntent.setAction(Intent.ACTION_SEND); // Native email client doesn't currently support HTML, but it doesn't hurt to try in case they fix it emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject); emailIntent.putExtra(Intent.EXTRA_TEXT, emailText); //emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(resources.getString(R.string.share_email_native))); emailIntent.setType("message/rfc822"); PackageManager pm = getPackageManager(); Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("text/plain"); Intent openInChooser = Intent.createChooser(emailIntent, resources.getString(R.string.share_chooser_text)); List<ResolveInfo> resInfo = pm.queryIntentActivities(sendIntent, 0); List<LabeledIntent> intentList = new ArrayList<LabeledIntent>(); for (int i = 0; i < resInfo.size(); i++) { // Extract the label, append it, and repackage it in a LabeledIntent ResolveInfo ri = resInfo.get(i); String packageName = ri.activityInfo.packageName; if (packageName.contains("android.email")) { emailIntent.setPackage(packageName); } else if (packageName.contains("twitter") || packageName.contains("facebook") || packageName.contains("whatsapp") || packageName.contains("tencent.mm") || //wechat packageName.contains("line") || packageName.contains("skype") || packageName.contains("viber") || packageName.contains("kik") || packageName.contains("sgiggle") || //tango packageName.contains("kakao") || packageName.contains("telegram") || packageName.contains("nimbuzz") || packageName.contains("hike") || packageName.contains("imoim") || packageName.contains("bbm") || packageName.contains("threema") || packageName.contains("mms") || packageName.contains("android.apps.messaging") || //google messenger packageName.contains("android.talk") || //google hangouts packageName.contains("android.gm")) { Intent intent = new Intent(); intent.setComponent(new ComponentName(packageName, ri.activityInfo.name)); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); if (packageName.contains("twitter")) { intent.putExtra(Intent.EXTRA_TEXT, twitterText); } else if (packageName.contains("facebook")) { /* * the warning below is wrong! at least on GS5, Facebook client does take * our text, however it seems it takes only the first hyperlink in the * text. * * Warning: Facebook IGNORES our text. They say "These fields are intended * for users to express themselves. Pre-filling these fields erodes the * authenticity of the user voice." * One workaround is to use the Facebook SDK to post, but that doesn't * allow the user to choose how they want to share. We can also make a * custom landing page, and the link will show the <meta content ="..."> * text from that page with our link in Facebook. */ intent.putExtra(Intent.EXTRA_TEXT, appLink); } else if (packageName.contains("tencent.mm")) //wechat { /* * wechat appears to do this similar to Facebook */ intent.putExtra(Intent.EXTRA_TEXT, appLink); } else if (packageName.contains("android.gm")) { // If Gmail shows up twice, try removing this else-if clause and the reference to "android.gm" above intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject); intent.putExtra(Intent.EXTRA_TEXT, emailText); //intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(resources.getString(R.string.share_email_gmail))); intent.setType("message/rfc822"); } else if (packageName.contains("android.apps.docs")) { /* * google drive - no reason to send link to it */ continue; } else { intent.putExtra(Intent.EXTRA_TEXT, emailText); } intentList.add(new LabeledIntent(intent, packageName, ri.loadLabel(pm), ri.icon)); } } /* * create "Copy Link To Clipboard" Intent */ Intent clipboardIntent = new Intent(this, CopyToClipboardActivity.class); clipboardIntent.setData(Uri.parse(appLink)); intentList.add(new LabeledIntent(clipboardIntent, getPackageName(), getResources().getString(R.string.clipboard_activity_name), R.drawable.ic_copy_link)); // convert intentList to array LabeledIntent[] extraIntents = intentList.toArray(new LabeledIntent[intentList.size()]); openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); startActivity(openInChooser); }
From source file:com.chummy.jezebel.material.dark.activities.Main.java
@Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) { case R.id.share: Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = "Check out " + getResources().getString(R.string.theme_name) + " by " + getResources().getString(R.string.nicholas_short) + "!\n\nDownload it here!: " + getResources().getString(R.string.play_store_link); sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title)))); break;// w w w .ja va 2 s . c o m case R.id.sendemail: StringBuilder emailBuilder = new StringBuilder(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + getResources().getString(R.string.email_id))); if (!isAppInstalled("org.cyanogenmod.theme.chooser")) { if (!isAppInstalled("com.cyngn.theme.chooser")) { if (!isAppInstalled("com.lovejoy777.rroandlayersmanager")) { intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject)); } else { intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_rro)); } } else { intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_cos)); } } else { intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_cm)); } emailBuilder.append("\n \n \nOS Version: " + System.getProperty("os.version") + "(" + Build.VERSION.INCREMENTAL + ")"); emailBuilder.append("\nOS API Level: " + Build.VERSION.SDK_INT + " (" + Build.VERSION.RELEASE + ") " + "[" + Build.ID + "]"); emailBuilder.append("\nDevice: " + Build.DEVICE); emailBuilder.append("\nManufacturer: " + Build.MANUFACTURER); emailBuilder.append("\nModel (and Product): " + Build.MODEL + " (" + Build.PRODUCT + ")"); if (!isAppInstalled("org.cyanogenmod.theme.chooser")) { if (!isAppInstalled("com.cyngn.theme.chooser")) { if (!isAppInstalled("com.lovejoy777.rroandlayersmanager")) { emailBuilder.append("\nTheme Engine: Not Available"); } else { emailBuilder.append("\nTheme Engine: Layers Manager (RRO)"); } } else { emailBuilder.append("\nTheme Engine: Cyanogen OS Theme Engine"); } } else { emailBuilder.append("\nTheme Engine: CyanogenMod Theme Engine"); } PackageInfo appInfo = null; try { appInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } emailBuilder.append("\nApp Version Name: " + appInfo.versionName); emailBuilder.append("\nApp Version Code: " + appInfo.versionCode); intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString()); startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title)))); break; case R.id.changelog: changelog(); break; case R.id.hide_launcher: boolean checked = item.isChecked(); if (!checked) { new MaterialDialog.Builder(this).title(R.string.warning).content(R.string.hide_action) .positiveText(R.string.nice).show(); } item.setChecked(!checked); setLauncherIconEnabled(checked); return true; default: return super.onOptionsItemSelected(item); } return true; }
From source file:com.googlecode.android_scripting.facade.AndroidFacade.java
@Rpc(description = "Launches an activity that sends an e-mail message to a given recipient.") public void sendEmail( @RpcParameter(name = "to", description = "A comma separated list of recipients.") final String to, @RpcParameter(name = "subject") final String subject, @RpcParameter(name = "body") final String body, @RpcParameter(name = "attachmentUri") @RpcOptional final String attachmentUri) { final Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(android.content.Intent.EXTRA_EMAIL, to.split(",")); intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); intent.putExtra(android.content.Intent.EXTRA_TEXT, body); if (attachmentUri != null) { intent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse(attachmentUri)); }/* ww w . ja v a 2 s. c o m*/ startActivity(intent); }
From source file:com.flipzu.flipzu.Player.java
private void share() { if (mUser == null || bcast == null) return;/* www . j ava 2 s .c om*/ //create the intent Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); //set the type shareIntent.setType("text/plain"); //add a subject shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mUser.getFullname() + " live on FlipZu"); String text = bcast.getText(); if (text == null) { text = mUser.getUsername() + " live on FlipZu"; } //build the body of the message to be shared String shareMessage = text + " - http://fzu.fm/" + bcast.getId(); //add the message shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); //start the chooser for sharing startActivity(Intent.createChooser(shareIntent, getText(R.string.share_bcast_with))); }
From source file:com.shollmann.igcparser.ui.activity.FlightPreviewActivity.java
private void launchShareFile(String tempIgcFilePath) { try {/*from w w w .java2s. co m*/ TrackerHelper.trackShareFlight(); Intent intentEmail = new Intent(Intent.ACTION_SEND); intentEmail.setType(Constants.App.TEXT_HTML); intentEmail.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(FlightPreviewActivity.this, Constants.App.FILE_PROVIDER, new File(tempIgcFilePath))); intentEmail.putExtra(Intent.EXTRA_SUBJECT, String.format(getString(R.string.share_email_subject), Uri.parse(tempIgcFilePath).getLastPathSegment())); startActivity(Intent.createChooser(intentEmail, getString(R.string.share))); } catch (Throwable t) { Toast.makeText(this, R.string.sorry_error_happen, Toast.LENGTH_SHORT).show(); } }
From source file:com.googlecode.CallerLookup.Main.java
public void doSubmit() { String entry = ""; if (mLookup.getSelectedItemPosition() != 0) { entry = mLookup.getSelectedItem().toString() + "\n"; }//from ww w . j a va 2 s. com entry += mURL.getText().toString() + "\n"; entry += mRegExp.getText().toString() + "\n"; try { String[] mailto = { EMAIL_ADDRESS }; Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto); sendIntent.putExtra(Intent.EXTRA_SUBJECT, EMAIL_SUBJECT); sendIntent.putExtra(Intent.EXTRA_TEXT, entry); sendIntent.setType("message/rfc822"); startActivity(sendIntent); } catch (ActivityNotFoundException e) { e.printStackTrace(); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.SubmitFailureTitle); alert.setMessage(R.string.SubmitFailureMessage); alert.setPositiveButton(android.R.string.ok, null); alert.show(); } }
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:/*www . j a v a 2s. c om*/ 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.geotrackin.gpslogger.GpsMainActivity.java
/** * Allows user to send a GPX/KML file along with location, or location only * using a provider. 'Provider' means any application that can accept such * an intent (Facebook, SMS, Twitter, Email, K-9, Bluetooth) *///from ww w . j av a 2s . c o m private void Share() { tracer.debug("GpsMainActivity.Share"); try { final String locationOnly = getString(R.string.sharing_location_only); final File gpxFolder = new File(AppSettings.getGpsLoggerFolder()); if (gpxFolder.exists()) { File[] enumeratedFiles = Utilities.GetFilesInFolder(gpxFolder); Arrays.sort(enumeratedFiles, new Comparator<File>() { public int compare(File f1, File f2) { return -1 * Long.valueOf(f1.lastModified()).compareTo(f2.lastModified()); } }); List<String> fileList = new ArrayList<String>(enumeratedFiles.length); for (File f : enumeratedFiles) { fileList.add(f.getName()); } fileList.add(0, locationOnly); final String[] files = fileList.toArray(new String[fileList.size()]); final ArrayList selectedItems = new ArrayList(); // Where we track the selected items AlertDialog.Builder builder = new AlertDialog.Builder(this); // Set the dialog title builder.setTitle(R.string.osm_pick_file) .setMultiChoiceItems(files, null, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if (isChecked) { if (which == 0) { //Unselect all others ((AlertDialog) dialog).getListView().clearChoices(); ((AlertDialog) dialog).getListView().setItemChecked(which, isChecked); selectedItems.clear(); } else { //Unselect the settings item ((AlertDialog) dialog).getListView().setItemChecked(0, false); if (selectedItems.contains(0)) { selectedItems.remove(selectedItems.indexOf(0)); } } selectedItems.add(which); } else if (selectedItems.contains(which)) { // Else, if the item is already in the array, remove it selectedItems.remove(Integer.valueOf(which)); } } }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (selectedItems.size() <= 0) { return; } final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("*/*"); if (selectedItems.get(0).equals(0)) { tracer.debug("User selected location only"); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.sharing_mylocation)); if (Session.hasValidLocation()) { String bodyText = getString(R.string.sharing_googlemaps_link, String.valueOf(Session.getCurrentLatitude()), String.valueOf(Session.getCurrentLongitude())); intent.putExtra(Intent.EXTRA_TEXT, bodyText); intent.putExtra("sms_body", bodyText); startActivity( Intent.createChooser(intent, getString(R.string.sharing_via))); } } else { intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.putExtra(Intent.EXTRA_SUBJECT, "Geotrackin (Android app): Here are some files."); intent.setType("*/*"); ArrayList<Uri> chosenFiles = new ArrayList<Uri>(); for (Object path : selectedItems) { File file = new File(gpxFolder, files[Integer.valueOf(path.toString())]); Uri uri = Uri.fromFile(file); chosenFiles.add(uri); } intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, chosenFiles); startActivity(Intent.createChooser(intent, getString(R.string.sharing_via))); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { selectedItems.clear(); } }); builder.create(); builder.show(); } else { Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this); } } catch (Exception ex) { tracer.error("Share", ex); } }