title: Sharing Image Using Intent on whats app getting error sharing failed
body: <p>I am loading single jpg image from drawable folder set file provider permission in manifest but when i share image on whatsapp i got error sharing failed please try again.When i share text it works fine but when i tried to share image it gives me error.Here is following files</p>
  
  <p><strong>Fullscreenadapter.java</strong></p>
  
  <pre><code>package com.mobdev.birthdaycakesquotes;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.content.res.Resources;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.net.Uri;
  import android.os.Environment;
  import android.support.v4.app.ShareCompat;
  import android.support.v4.content.FileProvider;
  import android.support.v4.view.PagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  
  
  public class Fullscreenadapter extends PagerAdapter {
  private Integer[] Image;
  private int _resource;
  private Activity _activity;
  private LayoutInflater inflater;
  private  String images;
  TextView t1,t2;
  public Fullscreenadapter(Activity activity,
                           Integer[] image) {
      this._activity = activity;
      this.Image=image;
  }
  
  @Override
  public int getCount() {
      return this.Image.length;
  }
  
  @Override
  public boolean isViewFromObject(View view, Object object) {
      return view == ((RelativeLayout) object);
  }
  @Override
  public Object instantiateItem(ViewGroup container, final int position) {
      final ImageView imgDisplay,shareimage;
  
  
      inflater = (LayoutInflater) _activity
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View viewLayout = inflater.inflate(R.layout.fullscreenlayoutdesign, 
    container,
              false);
  
      imgDisplay = (ImageView) viewLayout.findViewById(R.id.show);
      shareimage=(ImageView)viewLayout.findViewById(R.id.share);
      t1=(TextView)viewLayout.findViewById(R.id.currentposition);
      t2=(TextView)viewLayout.findViewById(R.id.totalimage);
  
  
      imgDisplay.setImageResource(Image[position]);
      t1.setText(String.valueOf(position));
      t2.setText(String.valueOf(Image.length));
      images=createImageOnSDCard(R.drawable.sw);
  
      shareimage.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
       Uri path = FileProvider.getUriForFile(_activity, 
      "com.mobdev.birthdaycakesquotes",new File(images));
  
  
              Intent shareIntent = new Intent();
              shareIntent.setAction(Intent.ACTION_SEND);
              shareIntent.putExtra(Intent.EXTRA_TEXT, "This is one image I'm 
     sharing.");
              shareIntent.putExtra(Intent.EXTRA_STREAM, path);
              shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
              shareIntent.setType("image/*");
              _activity.startActivity(Intent.createChooser(shareIntent, 
    "Share..."));
  
  
          }
      });
      ((ViewPager) container).addView(viewLayout);
      return viewLayout;
  }
  private String createImageOnSDCard(int resID) {
      Bitmap bitmap = BitmapFactory.decodeResource(Resources.getSystem(), resID);
      String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + resID + ".jpg";
      File file = new File(path);
      try {
          OutputStream out = new FileOutputStream(file);
          bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
          out.flush();
          out.close();
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      return file.getPath();
  }
  @Override
  public void destroyItem(ViewGroup container, int position, Object object) {
      ((ViewPager) container).removeView((RelativeLayout) object);
  }
  }
  </code></pre>
  
  <p><strong>AndroidManifestfile</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.mobdev.birthdaycakesquotes"&gt;
  
  &lt;application
      android:allowBackup="true"
      android:hardwareAccelerated="false"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:largeHeap="true"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@style/AppTheme.NoActionBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".HomePage"
          android:label="@string/title_activity_home_page"
          android:theme="@android:style/Theme.NoTitleBar.Fullscreen" /&gt;
      &lt;activity android:name=".Details_activity"&gt;&lt;/activity&gt;
  
      &lt;provider
          android:name="android.support.v4.content.FileProvider"
          android:authorities="com.mobdev.birthdaycakesquotes"
          android:grantUriPermissions="true"
          android:exported="false"&gt;
          &lt;meta-data
              android:name="android.support.FILE_PROVIDER_PATHS"
              android:resource="@xml/file_paths" /&gt;
      &lt;/provider&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>file_paths.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;external-path name="external_files" path="." /&gt;
  &lt;/paths&gt;
  </code></pre>