List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:Main.java
public static Intent getTakeGalleryIntent(Uri imageUri) { // Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); return intent; }
From source file:Main.java
public static void share(Context context, String title, String url) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, url); Intent chooserIntent = Intent.createChooser(shareIntent, title); chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(chooserIntent); }
From source file:Main.java
public static void forward(Context context, String body) { if (body != null) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, body); context.startActivity(intent);//from www .j a v a 2 s . c om } }
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 shareAppInfo(Context context, String info) { if (!TextUtils.isEmpty(info)) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, info); context.startActivity(intent);/*from w w w. j a v a 2 s. co m*/ } }
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); 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
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 {//ww w .j a va 2s . com context.startActivity(Intent.createChooser(intent, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { } }
From source file:Main.java
public static void forwardBySms(Context context, String body) { if (body != null) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType("vnd.android-dir/mms-sms"); // intent.putExtra("forwarded_message",true); // comment this may improve performance for forwarding sms intent.putExtra("sms_body", body); context.startActivity(intent);/*from www . ja v a 2s .c om*/ } }
From source file:Main.java
public static void shareFile(Context context, String title, String subject, String text, String mime, String path) {/* w ww. j a v a 2 s.co m*/ 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 boolean share(Context context, String title, String content) { Intent send = new Intent(Intent.ACTION_SEND); send.setType("text/plain"); send.putExtra(Intent.EXTRA_TEXT, content); send.putExtra(Intent.EXTRA_SUBJECT, title); try {//from w ww .ja v a2 s . c o m context.startActivity(Intent.createChooser(send, content)); } catch (android.content.ActivityNotFoundException ex) { return false; } return true; }