-1
我有一個gridview,單擊gridview中的任何圖像展開它到一個更大的圖像視圖,在這個圖像視圖我可以左右滑動來改變我的圖像,我已經添加了一個方法,可以讓我分享圖像到其他應用程序,如臉書watsapp等,但該方法似乎不太正確,我無法找出我的錯誤。它打開彈出窗口顯示共享圖像的選項,但是當我選擇任何選項發送圖像它說,無法加載圖像。共享內容
看一看我的代碼:
else {
if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
URL url2 = new URL((thumb[j]));
Bitmap bimage = BitmapFactory.decodeStream(url2
.openConnection().getInputStream());
shareImage();
Toast.makeText(getApplicationContext(),
"Saving to Favorites", Toast.LENGTH_LONG)
.show();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
private void shareImage() {
Intent share = new Intent(Intent.ACTION_SEND);
// If you want to share a png image only, you can do:
// setType("image/png"); OR for jpeg: setType("image/jpeg");
share.setType("image/*");
// Make sure you put example png image named myImage.png in your
// directory
String bimage = Environment.getExternalStorageDirectory()
+ thumb[j];
File imageFileToShare = new File(bimage);
Uri uri = Uri.fromFile(imageFileToShare);
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Image!"));
}
}
而拇指具有圖像的所有的資源ID陣列,「J」是誰的價值開始爲0
使用的INT啓動代碼的手勢。
我準備好分享我的完整代碼,以便更好地理解。
任何幫助將不勝感激。
你確定你在bimage中有東西嗎? – Pavya
@ user3676184我沒有得到你的問題,但是,是的,左右滑動可以改變我的圖像視圖中的圖像,這工作正常,現在只需要共享圖像視圖中的任何圖像。 –
http://stackoverflow.com/questions/7661875/how-to-use-share-image-using-sharing-intent-to-share-images-in-android檢查這個鏈接 – Pavya