Send Text Tag to Instagram using my Android app

非 Y 不嫁゛ 提交于 2019-11-30 05:17:37

问题


My app take pictures and send to instagram, facebook and twitter but I need to share the text "#myappname" with the picture in instagram.

Here's the code I use to send the photos

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/*");
caminhoImagens = getRealPathFromURI(Uri.parse(url));
Log.i("Caminho imagem: ", caminhoImagens);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + caminhoImagens));
shareIntent.setPackage("com.instagram.android");
startActivity(shareIntent);

I tried to use the codes below to send a text together but didn't work.

shareIntent.putExtra(Intent.EXTRA_TEXT,"#TEXT");
shareIntent.putExtra(Intent.EXTRA_TITLE,"#TEXT");
shareIntent.putExtra(Intent.EXTRA_SUBJECT,"#TEXT");

Someone know if there is a way to do that?

Thanks and regards.


回答1:


Finally Instagram API supports text coming from Android apps using Intent.

Here is the intent code to share image and text in Instagram.

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;

Here is the documentation




回答2:


It's not possible, since for now instagramm accepts only Intent.EXTRA_STREAM unfortunately. You can check same question here Open Instagram app from another android app and send an Image with a Caption




回答3:


If you're looking to interact with they're API's directly there is a lot of stuff you need to do that I'm not familiar with. However, if you want to share to any app on the device that accepts an image and text you can just run startActivity(); while passing in a proper Intent.

If you have time, I suggest you read the following Android Developer Blog post: Share With Intents

Or, have a look at the following quesiton on SO: flickr, tumblr , instagram share intent in android

Hopefully that is what you're trying to achieve.



来源:https://stackoverflow.com/questions/19258217/send-text-tag-to-instagram-using-my-android-app

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