title: Sharing Image to Instagram Story
body: <p>Using sharing <strong>intent</strong> i tried to upload image to <strong>Instagram</strong> using below code</p>
  
  <pre><code>  public static boolean shareBitmap(Context context, Bitmap bitmap, String textToShare, String packageNameOfApp,
                                    String intentMessage) {
      try {
          File file = new File(context.getCacheDir(), "Share.jpg");
          saveBitmapAtLocation(bitmap, Bitmap.CompressFormat.JPEG, 100, file);
          Uri contentUri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
          Intent intent = new Intent();
          intent.setAction(Intent.ACTION_SEND);
          intent.putExtra(Intent.EXTRA_STREAM, contentUri);
          String textToAppend = null;
          textToAppend = context.getString(R.string.shortenUrl);
          if (textToShare != null &amp;&amp; !textToShare.isEmpty())
              intent.putExtra(Intent.EXTRA_TEXT, textToShare + " " + textToAppend);
          else
              intent.putExtra(Intent.EXTRA_TEXT, textToAppend);
          intent.setType("image/*");
          List&lt;ResolveInfo&gt; resInfoList = context.getPackageManager().queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
          for (ResolveInfo resolveInfo : resInfoList) {
              String packageName = resolveInfo.activityInfo.packageName;
              context.grantUriPermission(packageName, contentUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
          }
          if (packageNameOfApp != null) {
              if (appInstalledOrNot((Activity) context, packageNameOfApp))
                  intent.setPackage(packageNameOfApp);
              else
                  return false;
          }
  
          context.startActivity(Intent.createChooser(intent, intentMessage));
      } catch (Exception e) {
          e.printStackTrace();
      }
      return true;
  }
  </code></pre>
  
  <p>When i try to post directly to the Instagram story it gives a black screen with a Toast message <em>Couldn't refresh feed</em></p>