List of usage examples for android.content Intent EXTRA_STREAM
String EXTRA_STREAM
To view the source code for android.content Intent EXTRA_STREAM.
Click Source Link
From source file:Main.java
public static Intent getShareImageIntent(Uri uri) { Intent image = new Intent(); image.setAction(Intent.ACTION_SEND); image.putExtra(Intent.EXTRA_STREAM, uri); image.setType("image/*"); return image; }
From source file:Main.java
public static Intent getAndroidImageShareIntent(CharSequence chooseTitle, String pathfile) { Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/*"); share.putExtra(Intent.EXTRA_STREAM, Uri.parse(pathfile)); return Intent.createChooser(share, chooseTitle); }
From source file:Main.java
public static void shareImage(Context context, Uri uri, String title) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/jpeg"); context.startActivity(Intent.createChooser(shareIntent, title)); }
From source file:Main.java
/** * Returns import source uri based on the Intent. *//* ww w . ja va2s. co m*/ static Uri getImportUri(Intent intent) { String action = intent.getAction(); if (Intent.ACTION_SEND.equals(action)) { return intent.getParcelableExtra(Intent.EXTRA_STREAM); } if (Intent.ACTION_VIEW.equals(action)) { return intent.getData(); } return null; }
From source file:Main.java
public static void sharePic(Uri uri, String desc, Context context) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/jpeg"); context.startActivity(Intent.createChooser(shareIntent, desc)); }
From source file:Main.java
public static void share(Context context, String imageFileLocation, String textToSend) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_TEXT, textToSend); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imageFileLocation))); context.startActivity(Intent.createChooser(intent, "Share with...")); }
From source file:Main.java
public static void shareFile(Context context, String title, String subject, String text, String mime, String path) {//from w w w .j a v a 2s.c o 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 void send(Context context, String path) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); PackageManager pm = context.getPackageManager(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path))); List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); boolean flag = false; for (ResolveInfo info : list) { if (info.activityInfo.packageName.toLowerCase().contains("bluetooth") || info.activityInfo.name.toLowerCase().contains("bluetooth")) { ApplicationInfo appInfo = null; try { appInfo = pm.getApplicationInfo(info.activityInfo.packageName, PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { }//from w w w.j av a 2 s . c o m if (appInfo != null && (appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0 && (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); flag = true; break; } } } if (!flag) { return; } context.startActivity(intent); }
From source file:Main.java
private static void shareImageOnFacebook(String imagePath, Context context) { Log.d("CitationsManager-ShareOnFb", "sharing the image " + imagePath); Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("image/*"); // shareIntent.putExtra(Intent.EXTRA_TEXT, "www.google.com"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath))); PackageManager pm = context.getPackageManager(); List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0); for (final ResolveInfo app : activityList) { Log.d("CitationsManager-ShareOnFb", app.activityInfo.name); if ((app.activityInfo.name).contains("com.facebook") && !(app.activityInfo.name).contains("messenger") && !(app.activityInfo.name).contains("pages")) { final ActivityInfo activity = app.activityInfo; final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name); shareIntent.addCategory(Intent.CATEGORY_LAUNCHER); shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); shareIntent.setComponent(name); context.startActivity(shareIntent); break; }//from w ww.ja v a2s .c o m } }
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);/*from www .j a va2s . co m*/ 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); }