1

I want an intent to open twitch profile of a user, but I don't know what to give in Uri.parse(?), I have tried this but isn't working Intent to open Instagram user profile on Android

public String username;

public Intent TwitchProfile(){
    Intent i;

    try {
        i = new Intent(Intent.ACTION_VIEW, Uri.parse("<what should I put here>://user?screen_name=" + username));
    }catch (Exception e) {
       i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.twitch.com/" + username));
    }
    return i;
}

1 Answers1

1

Try this:

Uri uri = Uri.parse("https://www.twitch.com/_u/" + username);

Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);

likeIng.setPackage("tv.twitch.android.viewer");

try {
    startActivity(likeIng);
} catch (ActivityNotFoundException e) {
    startActivity(new Intent(Intent.ACTION_VIEW,
            Uri.parse("https://www.twitch.com/"  + username)));
}

For more details, you can visit: https://dev.twitch.tv/docs/mobile-deeplinks/#launching-the-twitch-app

GOVIND DIXIT
  • 1,748
  • 10
  • 27