12

I know that this question has been asked several times before, I am trying to add caption to image shared to instagram using send intent

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_STREAM,uri);
shareIntent.putExtra(Intent.EXTRA_TEXT,"YOUR TEXT TO SHARE IN INSTAGRAM");
shareIntent.setPackage("com.instagram.android");
return shareIntent;

Has someone ever managed to make it work?

Is it not supported or has the support been revoked?

Vivek Barai
  • 1,338
  • 13
  • 26
ammcom
  • 992
  • 1
  • 7
  • 24
  • The `ACTION_SEND` procotol is documented to support *either* `EXTRA_TEXT` *or* `EXTRA_STREAM` on any given `Intent`. While some apps might support both, there is no requirement that any app do so. – CommonsWare Sep 17 '15 at 22:14
  • 1
    Someone stated that Instagram did support text extra while I can not manage to make it work, so I am asking particularly about instagram app – ammcom Sep 17 '15 at 22:19

4 Answers4

13

There was an official statement from Instagram (mid-2015) announcing that pre-populated captions would no longer be accepted in the iOS and Android apps:

Beginning today, the iOS Hooks and Android Intents will stop accepting captions passed by third party apps. This is a non-breaking change: existing mobile apps that utilize pre-filled captions will continue to be able to use this flow to share media through the Instagram apps, but now Instagram will ignore the caption text. To create a caption for a photo or video shared by a third party app, users will have to enter a caption manually, the same way they already do when sharing content using the Instagram native apps.

Looking at the Instagram documentation for Android, indeed we see that there's no mention of providing the conventional Intent.EXTRA_TEXT string extra in the intent as is customary for other apps. Their sample is limited to only providing a Uri:

// Add the URI to the Intent.
share.putExtra(Intent.EXTRA_STREAM, uri);

// Broadcast the Intent.
startActivity(Intent.createChooser(share, "Share to"));

I'm sorry to say that it simply isn't possible, and we're at the discretion of Facebook in making this decision.

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
7

Until it`s not solved by Instagram, I copy the text to the clipboard and instruct the user to paste it

0

I'm with the same problem. I think is not possible at this time.

In https://instagram.com/developer/mobile-sharing/android-intents/ only talk about Intent.EXTRA_STREAM, so i suppose that it's the only available.

Here is my code:

    Intent instagramIntent = new Intent(Intent.ACTION_SEND);
    instagramIntent.setType("image/*");
    File media = new File(mediaPath);
    Uri uri = Uri.fromFile(media);
    instagramIntent.putExtra(Intent.EXTRA_STREAM, uri);
    instagramIntent.setPackage("com.instagram.android");

    PackageManager packManager = getPackageManager();
    List<ResolveInfo> resolvedInfoList = packManager.queryIntentActivities(instagramIntent,  PackageManager.MATCH_DEFAULT_ONLY);

    boolean resolved = false;
    for(ResolveInfo resolveInfo: resolvedInfoList){
        if(resolveInfo.activityInfo.packageName.startsWith("com.instagram.android")){
            instagramIntent.setClassName(
                    resolveInfo.activityInfo.packageName,
                    resolveInfo.activityInfo.name );
            resolved = true;
            break;
        }
    }
    if(resolved){
        startActivity(instagramIntent);
    }else{
        Toast.makeText(PromocionarMain.this, "Instagram App is not installed", Toast.LENGTH_LONG).show();
    } 
Martín Huergo
  • 217
  • 2
  • 5
0

Instagram have stopped accepting pre-populated capitions to increase the quality of content in the system. See this post.

http://developers.instagram.com/post/125972775561/removing-pre-filled-captions-from-mobile-sharing

siliconeagle
  • 7,379
  • 3
  • 29
  • 41
  • Please don't post identical answers to multiple questions. Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, _tailor your answers to the question_. – josliber Dec 07 '15 at 17:30