List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:Main.java
public static void shareToOtherApp(Context context, String title, String content, String dialogTitle) { Intent intentItem = new Intent(Intent.ACTION_SEND); intentItem.setType("text/plain"); intentItem.putExtra(Intent.EXTRA_SUBJECT, title); intentItem.putExtra(Intent.EXTRA_TEXT, content); intentItem.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(Intent.createChooser(intentItem, dialogTitle)); }
From source file:Main.java
public static void startActivity(@NonNull Context context, @NonNull Intent intent, @Nullable CharSequence title) { if (hasResolution(context, intent)) { context.startActivity(intent);/*from w ww .ja va 2 s . c om*/ } else { context.startActivity(Intent.createChooser(intent, title)); } }
From source file:Main.java
public static void sendMail(Context context, String dstAddr, String subject, String text) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String[] address = { dstAddr }; emailIntent.putExtra(Intent.EXTRA_EMAIL, address); emailIntent.setType("message/rfc822"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(emailIntent, "Send mail...")); }
From source file:Main.java
public static void shareFile(Context context, String title, String subject, String text, String mime, String path) {// ww w. jav a 2 s . com Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(mime); sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + path)); sendIntent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(sendIntent, title)); }
From source file:Main.java
public static void shareText(Context context, String title, String subject, String text, String mime) { Intent share = new Intent(Intent.ACTION_SEND); share.setType(mime);//from www . ja va 2 s . com share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_DOCUMENT); // Add data to the intent, the receiving app will decide // what to do with it. share.putExtra(Intent.EXTRA_SUBJECT, subject); share.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(share, title)); }
From source file:Main.java
/** * Share App//from w ww. j ava 2 s .co m * * @param context */ public static void shareApp(Context context) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); String title = "Share NavigationFastFrame"; String extraText = "NavigationFastFrame is a very good Frame."; intent.putExtra(Intent.EXTRA_TEXT, extraText); //Share text. intent.putExtra(Intent.EXTRA_SUBJECT, title); context.startActivity(Intent.createChooser(intent, "Share this")); }
From source file:Main.java
/** * Propose user to send an email with pre-filled fields. */// ww w . ja va 2 s . c om public static void sendEMail(final Context context, final String dialogTitle, final String to, final String subject, final String body) { final Intent send = new Intent(Intent.ACTION_SENDTO); final String uriText = "mailto:" + Uri.encode(to) + "?subject=" + Uri.encode(subject) + "&body=" + Uri.encode(body); send.setData(Uri.parse(uriText)); context.startActivity(Intent.createChooser(send, dialogTitle)); }
From source file:Main.java
public static void sendEmail(Context context, String receiver, String subject, String body) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { receiver }); intent.putExtra(Intent.EXTRA_SUBJECT, subject); try {/*from w w w. j a v a2 s .c o m*/ context.startActivity(Intent.createChooser(intent, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { } }
From source file:Main.java
public static void chooserPics(Context context, int requestCode) { if (context == null) { return;//www . j a va 2s. c o m } try { Intent localIntent = new Intent(); localIntent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); localIntent.setType("image/*"); localIntent.setAction(Intent.ACTION_GET_CONTENT); if (context instanceof Activity) { ((Activity) context).startActivityForResult(Intent.createChooser(localIntent, "Select Picture"), requestCode); } else { localIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(Intent.createChooser(localIntent, "Select Picture")); } } catch (Exception e) { } }
From source file:Main.java
public static void sendMail(Context context, String[] mail, String subject, String body) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); // i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"}); // i.putExtra(Intent.EXTRA_SUBJECT, "subject of email"); // i.putExtra(Intent.EXTRA_TEXT , "body of email"); i.putExtra(Intent.EXTRA_EMAIL, mail); i.putExtra(Intent.EXTRA_SUBJECT, subject); i.putExtra(Intent.EXTRA_TEXT, body); try {/*from ww w. j av a 2 s . c om*/ context.startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(context, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } }