androidandroid-intentandroid-camerainstagram

Send Text Tag to Instagram using my Android app


My app takes pictures and sends it to Instagram, Facebook, and twitter but I need to share the text "#myappname" with the picture on 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");

Does someone know if there is a way to do that?

Thanks and regards.


Solution

  • 2024-06-20

    The Instagram API appears to no longer support text from Android Intent.

    Here are some documentation links to the Instagram API

    How to share on Feed

    How to share on Stories

    ORIGINAL ANSWER (OUTDATED)

    Instagram API supports text coming from Android apps using Intent.

    Here is the intent code for sharing images and text on 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