您好我嘗試使用共享對話框使用意圖與下面的代碼。我想同時分享圖片和文字。但我得到eror: Failed to insert image java.io.FileNotFoundException: No such file or directory
在Android中使用意圖分享圖像中的圖像
我的代碼如下,我做錯了什麼。代碼位於片段類中。
Bitmap image = bmResized;
String pathOfBmp = Images.Media.insertImage(getActivity().getContentResolver(), image, "twitter_image.jpg", null);
Uri bmpUri = Uri.parse(pathOfBmp);
Intent tweetIntent = new Intent(Intent.ACTION_SEND);
tweetIntent.setAction(Intent.ACTION_SEND);
tweetIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
tweetIntent.putExtra(Intent.EXTRA_TEXT, "here is the tweet text");
tweetIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
tweetIntent.setType("image/jpeg");
startActivity(Intent.createChooser(tweetIntent, "Share this via"));
哪裏是圖像文件?它是在Assets或drawablle還是文件系統? –
我嘗試使用圖像視圖中的圖像。我將圖像從圖像庫上傳到imageView,然後將圖像視圖中的圖像轉換爲位圖。 – saner