title: How can i send either an image or a video file using ACTION_SEND?
body: <p>I want to share either an image or a video file using <code>ACTION_SEND</code>.  So basically when the users taps on an image and selects "share image/video" it should send either the image selected or the video selected.  </p>
  
  <p>here is my code i am using:</p>
  
  <pre><code>if (filep != null) {
  
        }
        File sending=new File(filep);
        Intent intent = new Intent();
        intent.setAction(android.content.Intent.ACTION_SEND);
        intent.setDataAndType(Uri.fromFile(sending),getMimeType(sending.getAbsolutePath()));
        intent.putExtra(Intent.EXTRA_STREAM, sending);
        startActivity(Intent.createChooser(intent , "Share"));
      }
  
    private String getMimeType(String url)
      {
          String parts[]=url.split("\\.");
          String extension=parts[parts.length-1];
          String type = null;
          if (extension != null) {
              MimeTypeMap mime = MimeTypeMap.getSingleton();
              type = mime.getMimeTypeFromExtension(extension);
          }
          return type;
  </code></pre>
  
  <p>So when testing, it takes me to which app i want to use to share with i.e whatsapp, Facebook, email etc.  And then when selecting either one, it then says "sharing failed, please try again."  I can't seem to figure out why it doesn't work.  However i have the same code to display either image or video file full screen with <code>ACTION_VIEW</code> and that seems to work great but not with sharing.</p>
  
  <p>Can anyone assist please?</p>