title: Android Share Intent Image Sharing not working
body: <p>I am new to Android and is having problem sharing image through share intent. I have googled alot, tried various things but still could not find the solution. </p>
  
  <p>My code is: </p>
  
  <pre><code>            Intent shareIntent = new Intent(Intent.ACTION_SEND);
              shareIntent.setType("image/*");
              shareIntent.putExtra(Intent.EXTRA_STREAM,uri);
              this.startActivityForResult(Intent.createChooser(shareIntent,"Share with"),12);
  </code></pre>
  
  <p>I have checked the uri, the file saved is a bitmap and its returning file. But the image which shows during sharing is not valid. Gmail says it could not attach the attachment, messages app could not load the image.</p>
  
  <p>Text sharing is working fine.</p>
  
  <p>Basically I am writing a plugin for Unity. Here is my code on Unity Side:</p>
  
  <pre><code>string destination = Path.Combine(Application.persistentDataPath,"sharingImage" + ".png");
              if (!File.Exists(destination)) {
                  print("creating new file");
                  File.Create(destination);
              }
              File.WriteAllBytes(destination, bytes);
  
              print("destination= "+destination);
  
              AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
              AndroidJavaObject uriObject = uriClass.CallStatic&lt;AndroidJavaObject&gt;("parse","file://" + destination);
  
              using (AndroidJavaClass pluginClass = new AndroidJavaClass("com.kashiftasneem.sharelib.ShareController")) {
  
                  AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                  AndroidJavaObject jo = jc.GetStatic&lt;AndroidJavaObject&gt;("currentActivity");
  
                  pluginClass.CallStatic("Share",message,uriObject,jo,gameObject.name,destination);
              }
  </code></pre>
  
  <p>I am logging destination and uri, they are:</p>
  
  <blockquote>
    <p>destination=
    /data/data/com.kashiftasneem.shareandroidplugin2/files/sharingImage.png</p>
    
    <p>uri =
    file:///data/data/com.kashiftasneem.shareandroidplugin2/files/sharingImage.png</p>
  </blockquote>