Search code examples
android-sharing

Result code for sharing intent for instagram android


Result code always gives 0 if i successfully shared an image with instagram via intent. Please help. Thanks in advance.

I have tried a lot.

This is my code :

File imageFileToShare = new File(filePath);
            Uri uri = Uri.fromFile(imageFileToShare);
            Intent shareInstagramIntent = new Intent(Intent.ACTION_SEND);
            shareInstagramIntent.setPackage("com.instagram.android");
            shareInstagramIntent.putExtra(Intent.EXTRA_STREAM, uri);
            shareInstagramIntent.setType("image/*");
            shareInstagramIntent.putExtra(Intent.EXTRA_TEXT, text);
            startActivityForResult(shareInstagramIntent, INSTAGRAM);

This is my onActivityResult :

public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case INSTAGRAM:
            logI("Request e: " + resultCode);
            if (resultCode == thisActivity.RESULT_OK) {
                Utilities.showAlert(thisActivity, "Image shared with instagram successfully");
                new PostPointsTask("instagram").execute("");
            } else {
                Utilities.showAlert(thisActivity, "Image shared with instagram was cancelled");
            }
}
}

Solution

  • There is no callback from instagram for share intent ,better use instagram sdk to share your message.