Guest User

Untitled

a guest
Jul 1st, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1.                             Bitmap bitmap = response.getBitmap();
  2.    
  3.                             File newFile = getActivity().getFilesDir();
  4.                    
  5.                             File f = new File(newFile, "share.jpg");
  6.                             FileOutputStream fos;
  7.  
  8.                             try {
  9.  
  10.                                 fos = getActivity().openFileOutput("share.jpg",Context.MODE_PRIVATE);
  11.                                 bitmap.compress(Bitmap.CompressFormat.JPEG, 85, fos);
  12.                                 fos.flush();
  13.                                 fos.close();
  14.  
  15.  
  16.                             } catch (FileNotFoundException e) {
  17.                                 e.printStackTrace();
  18.  
  19.                                 Utility.showLog(TAG,e.getLocalizedMessage());
  20.  
  21.                             } catch (IOException e) {
  22.  
  23.                                 e.printStackTrace();
  24.                                 Utility.showLog(TAG,e.getLocalizedMessage());
  25.                             }
  26.  
  27.  
  28.                             Intent intent = new Intent(Intent.ACTION_SEND);
  29.                             intent.setType("image/*");
  30.                             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  31.                             intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
  32.  
  33.                             intent.putExtra(Intent.EXTRA_SUBJECT, sp.getString(Utility.NAME_KEY, "Guest") + " shared this item with you from KicksExchange");
  34.                             intent.putExtra(Intent.EXTRA_TEXT,
  35.                                     "Check this out on KicksExchange " + pModel.getProductTitle() + " for $" + pModel.getProductPrice() + "\n\nGet the app if you don't have it");
  36.                             startActivity(intent);
Add Comment
Please, Sign In to add comment