ورود

View Full Version : گزینه ی اشتراک برای عکس



roboman78
یک شنبه 23 آذر 1393, 22:27 عصر
توی خیلی نرم افزارا واسه یه ایمیج ویو گزینه ی اشتراک وجود داره
میشه یکی کد یه همچین چیزی رو اینجا بزاره
مرسی؟

android2015
سه شنبه 25 آذر 1393, 23:30 عصر
از این کد استفاده کنید:


try {

Bitmap icon = Bmp_BG;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
fo.close();
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM, Uri.parse( "file:///" + Environment.getExternalStorageDirectory().getPath( ) + "/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));



} catch (Exception e) {
// TODO: handle exception
}

roboman78
چهارشنبه 26 آذر 1393, 20:22 عصر
مرسی دوست عزیز