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.
Asked
Active
Viewed 1.3k times
2
-
Call Instagram package name into intent directly so it will not display share via dialog. – Dipak Keshariya Nov 01 '12 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 Nov 02 '12 at 06: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 Nov 10 '15 at 17:07
2 Answers
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;
}

sembozdemir
- 4,137
- 3
- 21
- 30
-
Maybe add checks if instagram is installed? (by PackageManager) otherwise it may crash. – Talha Nov 26 '16 at 12:47
-
But after the Sharing is done, will the Instagram app redirect the user back to our App? – Sri Krishna May 30 '18 at 06:41
-2
Create your custom sharing screen that call instagram.

Yahor10
- 2,123
- 1
- 13
- 13
-
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 Nov 02 '12 at 06:37
-
1Create dialog view with instagram button. See this article:http://megadarja.blogspot.com/2011/10/appchooser.html – Yahor10 Nov 02 '12 at 07:01
-
But I don't need dialog with choose. I need by click on ImageButton post Image to app insragram – Ljudmila Nov 02 '12 at 07:06
-
send intent with package name of instagram application(com.instagram.android). See this post how do it http://stackoverflow.com/questions/2780102/open-another-application-from-your-own-intent – Yahor10 Nov 02 '12 at 07:42
-
com.instagram.android - NotFoundException: No Activity found to handle Intent { act=com.instagram.android }. I have tried this issue – Ljudmila Nov 02 '12 at 08:02
-
1see your the package name of your instagramm app from package manager.Have you install intagram app to your phone? – Yahor10 Nov 02 '12 at 08:04
-
Yes I have instll instagram, but don't get any information about Instagram package – Ljudmila Nov 02 '12 at 08:23
-
I have 9 reputation - I can't use chat in this site. maybe skype? I have information througth PackageManager that Instagram on my phone is - com.instagram.android.activity.MainTabActivity. but if i use this package I have classNotfoundexception. – Ljudmila Nov 02 '12 at 08:41
-
I have tried `final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List pkgAppsList = this.getPackageManager().queryIntentActivities( mainIntent, 0);` – Ljudmila Nov 02 '12 at 08:44