0

How to open Instagram app in posting mode (so the same view we get after clicking plus at home screen within Instagram app)? I've seen android apps which are doing that, however wasn't able to find information explaing how to achieve it.

That code works for opening the home view:

Uri uri = Uri.parse("http://instagram.com/");
Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);
likeIng.setPackage("com.instagram.android");
startActivity(likeIng);

Perhaps there is some other uri which could work?

Paavo
  • 21
  • 3

3 Answers3

2

After a bit of research it turned out that deep linking with 'instagram://share' opens the desired view.

Paavo
  • 21
  • 3
0

You can do that only when you have a media to share on Instagram:

try {
        String type = "image/*";
        String filename = "/myPhoto.jpg";
        String mediaPath = Environment.getExternalStorageDirectory() + filename;
        Intent share = new Intent(Intent.ACTION_SEND);
        share.setPackage("com.instagram.android");
        share.setType(type);
        File media = new File(mediaPath);
        Uri uri = null;
        share.putExtra(Intent.EXTRA_STREAM, uri);
        startActivity(share);
    } catch (Exception e) {
        e.printStackTrace();
    }

You can create a fake media though to be able to use this method.

sajjad
  • 834
  • 6
  • 13
0

Just to expand on @Paavo answer to show the answer in code.

Uri uri = Uri.parse("instagram://share");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setPackage("com.instagram.android");

//Check that the user can open the intent, meaning they have the Instagram app installed
if (getPackageManager().resolveActivity(intent, 0) != null)
    startActivity(intent);
else //User doesn't have app installed, handle however you want
    throw new Resources.NotFoundException();