title: Send the image to another application
body: <p>I'm trying to implement the "share" button. It is necessary to send a picture.</p>
  
  <p>That's what I'm doing:</p>
  
  <pre><code>Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
  
  File outputDir = context.getCacheDir();
  File outputFile = null;
  try {
      outputFile = File.createTempFile("temp_", ".jpg", outputDir);
  } catch (IOException e) {
      e.printStackTrace();
  }
  
  FileOutputStream fileOutputStream = null;
  try {
      fileOutputStream = new FileOutputStream(outputFile);
  } catch (FileNotFoundException e) {
      e.printStackTrace();
  }
  
  bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
  
  try {
      fileOutputStream.close();
  } catch (IOException e) {
      e.printStackTrace();
  }
  
  Intent shareIntent = new Intent();
  shareIntent.setAction(Intent.ACTION_SEND);
  shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(outputFile));
  shareIntent.setType("image/jpeg");
  startActivity(Intent.createChooser(shareIntent, 
  getResources().getText(R.string.send_via)));
  </code></pre>
  
  <p>but I get a message saying that it's impossible to upload an image. What's the matter?</p>