List of usage examples for android.content Intent EXTRA_TEXT
String EXTRA_TEXT
To view the source code for android.content Intent EXTRA_TEXT.
Click Source Link
From source file:Main.java
public static void shareOnFacebook(Context pContext, String urlToShare) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); // intent.putExtra(Intent.EXTRA_SUBJECT, "Foo bar"); // NB: has no effect! intent.putExtra(Intent.EXTRA_TEXT, urlToShare); // See if official Facebook app is found boolean facebookAppFound = false; List<ResolveInfo> matches = pContext.getPackageManager().queryIntentActivities(intent, 0); for (ResolveInfo info : matches) { if (info.activityInfo.packageName.toLowerCase().startsWith("com.facebook.katana")) { intent.setPackage(info.activityInfo.packageName); facebookAppFound = true;/*from w w w . j a v a 2 s . co m*/ break; } } // As fallback, launch sharer.php in a browser if (!facebookAppFound) { String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + urlToShare; intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl)); } pContext.startActivity(intent); }
From source file:Main.java
public static void showEmailDialog(final Context context, final String subject) { new AlertDialog.Builder(context).setTitle("Email Us").setMessage( "Please send email with As many details as possible. We will look into it as soon as possible. \n\nPlease DO NOT change subject and email address. Continue to Email?") .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override//from www .j a v a2s . c o m public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/html"); // intent.putExtra(Intent.EXTRA_EMAIL, R.string.app_email); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, ""); context.startActivity(Intent.createChooser(intent, "Send Email")); } }).setIcon(android.R.drawable.ic_dialog_info).show(); }
From source file:Main.java
public static Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType);/* w w w. j a v a 2s. c o m*/ if (attachments.length > 1) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); final ArrayList<CharSequence> textExtra = new ArrayList<>(); textExtra.add(text); intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, textExtra); final ArrayList<Parcelable> uris = new ArrayList<>(); Collections.addAll(uris, attachments); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, text); if (attachments.length > 0) { intent.putExtra(Intent.EXTRA_STREAM, attachments[0]); } } return intent; }
From source file:Main.java
public static Intent getAndroidShareIntent(CharSequence chooseTitle, CharSequence subject, CharSequence content) {//from ww w .j a va 2 s. c o m Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); shareIntent.putExtra(Intent.EXTRA_TEXT, content); return Intent.createChooser(shareIntent, chooseTitle); }
From source file:Main.java
/** * Drafts an email to the given email address, with the given subject line and message * @param context// w ww .ja va 2 s . c o m * @param emailAddress * @param subject * @param message */ public static void emailDeveloper(Context context, String emailAddress, String subject, String message) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { emailAddress }); i.putExtra(Intent.EXTRA_SUBJECT, subject); i.putExtra(Intent.EXTRA_TEXT, message); context.startActivity(i); }
From source file:Main.java
public static Intent getSendIntent(Context context, String title, String text) { if (TextUtils.isEmpty(text)) throw new IllegalArgumentException("text cannot be empty or null"); if (TextUtils.isEmpty(title)) throw new IllegalArgumentException("title cannot be empty or null"); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, text); sendIntent.setType("text/plain"); return Intent.createChooser(sendIntent, title); }
From source file:Main.java
public static boolean sendMail(Context context, String destination, String subject, String body) { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String aEmailList[] = { destination }; emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); if (subject != null) { emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); }/*from ww w. ja va2s . com*/ if (body != null) { emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); } emailIntent.setType("plain/text"); boolean ret = true; try { context.startActivity(emailIntent); } catch (Exception e) { ret = false; } return ret; }
From source file:Main.java
public static void sendFeedback2(Context context) { String versionName = ""; try {/*from w w w . jav a 2 s.c om*/ versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } StringBuffer sb = new StringBuffer(); sb.append("We would like to hear your feedback and improvement ideas. Please feel free to share below :") .append("\r\n").append("\r\n").append("\r\n").append("Attach Screenshots (if any) : ") .append("\r\n").append("\r\n").append("\r\n").append("Running on ").append(android.os.Build.MODEL) .append("\r\n").append("OS Version : ").append(android.os.Build.VERSION.RELEASE).append("\r\n") .append("Client Version : ").append(versionName); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "messageplus_feedback@starhub.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Message+ - Feedback"); emailIntent.putExtra(Intent.EXTRA_TEXT, sb.toString()); context.startActivity(Intent.createChooser(emailIntent, "Choose email client")); }
From source file:Main.java
public static void addToPocket(Context context, String url, String tweetStatusId) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setPackage(PACKAGE);//from w w w. ja va 2 s .c om intent.setType(MIME_TYPE); intent.putExtra(Intent.EXTRA_TEXT, url); if (tweetStatusId != null && tweetStatusId.length() > 0) { intent.putExtra(EXTRA_TWEET_STATUS_ID, tweetStatusId); } intent.putExtra(EXTRA_SOURCE_PACKAGE, context.getPackageName()); context.startActivity(intent); }
From source file:Main.java
public static void ShareApplication(Context mContext) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_SUBJECT, "Search Sri Lanka Railway Time Table"); intent.putExtra(Intent.EXTRA_TITLE, "Search Sri Lanka Railway Time Table"); intent.putExtra(Intent.EXTRA_TEXT, "Search \"Sri Lanka Railway Time Table\" on your Android. http://market.android.com/details?id=com.aselalee.trainschedule"); mContext.startActivity(Intent.createChooser(intent, "Spread the word")); return;//from ww w .j av a2 s . c om }