List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:Main.java
/** * Send an email via available mail activity * /*w w w.j a v a 2 s. co m*/ * @param context the app context * @param to the email address send to * @param subject the email subject * @param body the email body */ public static void sendEmail(Context context, String to, String subject, String body) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", to, null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); context.startActivity(Intent.createChooser(emailIntent, null)); }
From source file:Main.java
public static void share(Context context, String textToSend) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, textToSend); context.startActivity(Intent.createChooser(intent, "Share with...")); }
From source file:Main.java
public static Intent getEmailIntent(String toEmailAdr, String subject, String message, File attachmentFile, String intentChooserTitle) { String uriText = "mailto:" + toEmailAdr + "?subject=" + Uri.encode(subject) + "&body=" + Uri.encode(message);//w w w . j a v a2 s . c om Uri uri = Uri.parse(uriText); Intent sendIntent = new Intent(Intent.ACTION_SENDTO); sendIntent.setData(uri); if (attachmentFile != null) sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(attachmentFile)); return Intent.createChooser(sendIntent, intentChooserTitle); }
From source file:Main.java
private static void shareAct(Activity act, String fileName, String text) { Uri uri = null;/*from w ww . j av a 2s .c om*/ try { FileInputStream input = act.openFileInput(fileName); Bitmap bitmap = BitmapFactory.decodeStream(input); uri = Uri.parse(MediaStore.Images.Media.insertImage(act.getContentResolver(), bitmap, null, null)); input.close(); } catch (Exception e) { e.printStackTrace(); } Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/jpeg"); act.startActivity(Intent.createChooser(shareIntent, act.getTitle())); }
From source file:Main.java
public static void shareText(Context context, String title, String text) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, title); intent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(intent, title)); }
From source file:Main.java
public static void shareText(Context ctx, String title, String text) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); //intent.putExtra(Intent.EXTRA_SUBJECT, title); intent.putExtra(Intent.EXTRA_TEXT, text); ctx.startActivity(Intent.createChooser(intent, title)); /* List<ResolveInfo> ris = getShareTargets(ctx); if (ris != null && ris.size() > 0) { ctx.startActivity(Intent.createChooser(intent, title)); }*//*from w w w. j a v a2 s . co m*/ }
From source file:Main.java
public static void shareFile(Context context, String title, String filePath) { Intent intent = new Intent(Intent.ACTION_SEND); Uri uri = Uri.parse("file://" + filePath); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_STREAM, uri); context.startActivity(Intent.createChooser(intent, title)); }
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 ww w. j a va2s. com*/ 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 void email(Context context, String to, String subject, String body) { Intent send = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode(to) + "?subject=" + Uri.encode(subject) + "&body=" + Uri.encode(body);/*from w w w .ja va 2 s. co m*/ Uri uri = Uri.parse(uriText); send.setData(uri); context.startActivity(Intent.createChooser(send, "E-Mail senden")); }
From source file:Main.java
public static Intent getAndroidShareIntent(CharSequence chooseTitle, CharSequence subject, CharSequence content) {//from w ww .j a v a 2s . c om 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); }