Share to instagram without login to instagram app in android

I am using below code to share images and text on instagram:

public void ShareInstagram() {
        Log.e("SHARE", "IN INSTAGRAM");
        Intent intent = getActivity().getPackageManager()
                .getLaunchIntentForPackage("com.instagram.android");
        if (intent != null) {
            String type = "image/*";
            Intent share = new Intent(Intent.ACTION_SEND);
            share.setType(type);

            share.putExtra(Intent.EXTRA_STREAM, file);
            share.putExtra(Intent.EXTRA_TEXT, SHARE_NAME);
            share.setPackage("com.instagram.android");
            share.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            // Broadcast the Intent.
            startActivity(share);
        } else {
            Intent inplay = new Intent(Intent.ACTION_VIEW);
            inplay.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            inplay.setData(Uri.parse("market://details?id="
                    + "com.instagram.android"));
            startActivity(inplay);
        }

    }

      

when i share with my app on instagram and i am not registered with instagram then it opens the login or registration screen of the instagram app and displays a message for toast which needs to be logged in to share. and after that, when I click the back button, I go to my app with the sharing activity resume. but i couldnt access the screen. if i go back again then only i can access it.

this problem only occurs when i am not logged into instagram app. Help me with the right solution.

+3


source to share


1 answer


I noticed this problem as well. It seems to be the instagram version issue. I used the old one. After updating to the latest version, this issue has been resolved.



-1


source







All Articles