【发布时间】:2017-07-09 15:14:53
【问题描述】:
是否可以使用 android 共享对话框将图像和文本共享到 facebook、instagram 和 whatsapp?我正在尝试 2 周来做到这一点,但没有成功。我唯一能做的就是在不使用共享对话框的情况下为每个媒体编写一些代码。这是一些适用于 whatsapp 但不适用于 insta 和 facebook 的代码
String DishImage = listDishes.get(selectedDish).getDishImage();
Picasso.with(this).load(DishImage).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bm, Picasso.LoadedFrom from) {
OutputStream fOut = null;
Uri outputFileUri;
try {
File root = new File(Environment.getExternalStorageDirectory() + File.separator + "FoodMana" + File.separator);
root.mkdirs();
File sdImageMainDirectory = new File(root, "myPicName.jpg");
fOut = new FileOutputStream(sdImageMainDirectory);
} catch (Exception e) {Toast.makeText(getApplicationContext(), "Error occured. Please try again later.", Toast.LENGTH_SHORT).show();}
try {
bm.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
} catch (Exception e) {
}
Intent waIntent = new Intent(android.content.Intent.ACTION_SEND);
waIntent.setType("image/*");
waIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory()
+ File.separator + "FoodMana" + File.separator + "myPicName.jpg"));
waIntent.putExtra(Intent.EXTRA_TEXT, "I am going to eat that dish!!!!!" + "\n" + "what do you think? check out");
startActivity(Intent.createChooser(waIntent, "Share with"));
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
Log.d("TAG","error");
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
Log.d("TAG","prepared");
}
});
【问题讨论】:
标签: android