Instagram

Capture and share the world's moments.

Android Intents

If your application creates photos or videos and you would like your users to share them using Instagram, you can use Android Intents to open your media in Instagram's sharing flow.

The examples below create an Implicit Intent which will then prompt the user to select the application they wish to send the media to. When triggered, Instagram will immediately present the user with the crop screen.

Important Note

Adding a caption via Intent.EXTRA_TEXT is only available on Instagram 6.1.0 and later. Older versions of the Instagram app will ignore this parameter if it is present.

Intent Parameter Description
Intent.EXTRA_STREAM media path on device
Intent.EXTRA_TEXTcaption (media description)

Sharing an image

Requirement Value
Photo Format jpeg, gif, png
String type = "image/*"; String filename = "/myPhoto.jpg"; String mediaPath = Environment.getExternalStorageDirectory() + filename; String captionText = "<< media caption >>"; createInstagramIntent(type, mediaPath , captionText ); private void createInstagramIntent(String type, String mediaPath , String caption ){ // Create the new Intent using the 'Send' action. Intent share = new Intent(Intent.ACTION_SEND); // Set the MIME type share.setType(type); // Create the URI from the media File media = new File(mediaPath); Uri uri = Uri.fromFile(media); // Add the URI and the caption to the Intent. share.putExtra(Intent.EXTRA_STREAM, uri ); share.putExtra(Intent.EXTRA_TEXT, caption ); // Broadcast the Intent. startActivity(Intent.createChooser(share, "Share to")); } 

Sharing a video

Requirement Value
Minimum Duration 3 seconds
Maximum Duration 10 minutes
Video Format mkv, mp4
Minimum Dimensions 640x640 pixels
String type = "video/*"; String filename = "/myVideo.mp4"; String mediaPath = Environment.getExternalStorageDirectory() + filename; String captionText = "<< media caption >>"; createInstagramIntent(type, mediaPath , captionText ); private void createInstagramIntent(String type, String mediaPath , String caption ){ // Create the new Intent using the 'Send' action. Intent share = new Intent(Intent.ACTION_SEND); // Set the MIME type share.setType(type); // Create the URI from the media File media = new File(mediaPath); Uri uri = Uri.fromFile(media); // Add the URI and the caption to the Intent. share.putExtra(Intent.EXTRA_STREAM, uri ); share.putExtra(Intent.EXTRA_TEXT, caption ); // Broadcast the Intent. startActivity(Intent.createChooser(share, "Share to")); }