2

please help! I want share my photo into Instagram. I use Intent for sharing, but I don't need at all list in Share, such as - Facebook, Instagram, Gmail, Bluetoth... etc. I need only Instagram. I want share photo into Instagram by only onclickListener. How can do it? thanks.

3
  • Call Instagram package name into intent directly so it will not display share via dialog. Commented Nov 1, 2012 at 13:08
  • Please show me code, how can call package of instagram, because I don't found this. I do like this: Intent i = new Intent(Intent.ACTION_SEND); i.setType("image/jpeg"); i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Path/To/Image.jpg")); startActivity(Intent.createChooser(i, "Share Image"));
    – Ljudmila
    Commented Nov 2, 2012 at 6:31
  • You can set package name when you create an intent. Remember to put your intent in an try catch clause in case the target user doesn't have instagram app
    – hadi
    Commented Nov 10, 2015 at 17:07

2 Answers 2

9

It is asked a long time ago. But the clear answer is not here. That's why, I want to answer as well.

I have been used that code below and it worked. It redirects to crop screen of instagram directly. (Of course, Instagram app must be installed on the device.)

...
Intent intent = createInstagramIntent("file://" + filePath);
startActivity(intent);
...

and

private Intent createInstagramIntent(String uriString) {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(uriString));
    shareIntent.setPackage("com.instagram.android");
    return shareIntent;
}
2
  • Maybe add checks if instagram is installed? (by PackageManager) otherwise it may crash.
    – Talha
    Commented Nov 26, 2016 at 12:47
  • But after the Sharing is done, will the Instagram app redirect the user back to our App? Commented May 30, 2018 at 6:41
-2

Create your custom sharing screen that call instagram.

9
  • Please show me sample code, how can call package of instagram, because I don't found this. I do like this: Intent i = new Intent(Intent.ACTION_SEND); i.setType("image/jpeg"); i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Path/To/Image.jpg")); startActivity(Intent.createChooser(i, "Share Image"));
    – Ljudmila
    Commented Nov 2, 2012 at 6:37
  • 1
    Create dialog view with instagram button. See this article:megadarja.blogspot.com/2011/10/appchooser.html
    – Yahor10
    Commented Nov 2, 2012 at 7:01
  • But I don't need dialog with choose. I need by click on ImageButton post Image to app insragram
    – Ljudmila
    Commented Nov 2, 2012 at 7:06
  • send intent with package name of instagram application(com.instagram.android). See this post how do it stackoverflow.com/questions/2780102/…
    – Yahor10
    Commented Nov 2, 2012 at 7:42
  • 1
    see your the package name of your instagramm app from package manager.Have you install intagram app to your phone?
    – Yahor10
    Commented Nov 2, 2012 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.