Instagram from Android open on certain user and add caption to uploaded image

 ̄綄美尐妖づ 提交于 2019-11-30 10:51:53

It looks as if Instagram's Android App ignores EXTRA_TEXT, EXTRA_SUBJECT and EXTRA_TITLE, so it seems that adding a caption while uploading an image is not possible. By the way, you can try different approaches to check if it ignores those extras in every case:

OPTION #1: Changing the MIME type.

You are setting the MIME type to "image/jpeg". Try using "image/" or "/*" to check if their app doesn't ignore those extras.

share.setType("image/*");

or

share.setType("*/*");

OPTION #2:

As you are sending multiple MIME types (image and text), maybe their app is expecting ACTION_SEND_MULTIPLE instead of ACTION_SEND.

Intent share = new Intent(Intent.ACTION_SEND_MULTIPLE);

OPTION #3: Use MediaStore.Images.Media.insertImage(ContentResolver cr, String imagePath, String name, String description) function:

Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), "file:///" + path to myfile.png", "Sample title", "Sample description")));
share.setType("image/jpeg");
share.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);

OPTION #4: Post your issue in their developer forum, although there are similar questions that remain unsolved:

And don't forget to come back and tell us their answer!

It looks like Instagram has updated their app to accept EXTRA_TEXT to add a caption. If the user has an updated version of Instagram (July 1, 2014 version or later) you can post an image and add a caption with the following code:

Intent instagram = new Intent(android.content.Intent.ACTION_SEND);
instagram.setType("image/*");
instagram.putExtra(Intent.EXTRA_STREAM, [URI of photo]);
instagram.putExtra(Intent.EXTRA_TEXT, [Text of caption]);
instagram.setPackage(instagramPackageName);
startActivity(instagram);

Users with older versions will still get the image, but not have the caption be pre populated.

This code is assuming you have already been through the auth flow.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!