Guest User

Untitled

a guest
Dec 15th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. holder.shareBtn.setOnClickListener(new View.OnClickListener() {
  2. @Override
  3. public void onClick(View view) {
  4. Intent intent;
  5. Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), holder.imgView.getId());
  6.  
  7. String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) +"/share.png";
  8.  
  9. FileOutputStream out = null;
  10.  
  11. File file = new File(path);
  12.  
  13. try{
  14. out = new FileOutputStream(file);
  15. bitmap.compress(Bitmap.CompressFormat.PNG,100,out);
  16. out.flush();
  17. out.close();
  18.  
  19. }catch(Exception e){
  20. e.printStackTrace();
  21. }
  22.  
  23. path = file.getPath();
  24.  
  25. Uri bmpUri = Uri.parse("file://" + path);
  26.  
  27. intent = new Intent(Intent.ACTION_SEND);
  28. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  29. intent.putExtra(Intent.EXTRA_STREAM, bmpUri);
  30. intent.setType("image/jpeg");
  31. intent.putExtra(Intent.EXTRA_TEXT," Hello Your's Images ");
  32. context.startActivity(Intent.createChooser(intent, " Share Images Via"));
  33.  
  34.  
  35. }
Add Comment
Please, Sign In to add comment