View Full Version : گزینه ی اشتراک برای عکس
  
roboman78
یک شنبه 23 آذر 1393, 23:27 عصر
توی خیلی نرم افزارا واسه یه ایمیج ویو گزینه ی اشتراک وجود داره
میشه یکی کد یه همچین چیزی رو اینجا بزاره
مرسی؟
android2015
چهارشنبه 26 آذر 1393, 00: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, 21:22 عصر
مرسی دوست عزیز
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.