I'm able to start Twitter application (if it exists on the phone), yet I can't find how to automatically display a specific user profile.
Something like this works for Google+:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.google.android.apps.plus", "com.google.android.apps.plus.phone.UrlGatewayActivity");
intent.putExtra("customAppUri", "USER_ID");
Here is the Facebook way:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/USER_ID"));
startActivity(intent);
There should be the same kind of solution when I start Twitter app ?
Intent intent = getPackageManager().getLaunchIntentForPackage("com.twitter.android");
intent.putExtra("WHAT_TO_PUT_HERE?", "USER_ID");
startActivity(intent);
Click on the Apps and select Manage Apps. Now, click on the three-dots menu at the top and choose Default Apps. Scroll down, and click on Opening Links. Tap on the app for which you want to links to open in-app instead of browser.
The Twitter for Android app is available for phones running Android OS versions 7.93. 4 and above. Note: We no longer support older versions of Twitter for Android. To experience the most up-to-date Twitter for Android experience, download the latest version in the store or visit twitter.com in your browser.
Open the Google Play app or another app store that features the Twitter for Android app. Search for Twitter for Android. Select Download and accept the permissions. Once the Twitter for Android app finishes downloading, open the app and sign in.
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=" + twitter_user_name)));
}catch (Exception e) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/#!/" + twitter_user_name)));
}
This is working fine with the new Twitter app. Solution provided by @Baptiste Costa didn't work for me.
try
{
// Check if the Twitter app is installed on the phone.
getPackageManager().getPackageInfo("com.twitter.android", 0);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.twitter.android", "com.twitter.android.ProfileActivity");
// Don't forget to put the "L" at the end of the id.
intent.putExtra("user_id", 01234567L);
startActivity(intent);
}
catch (NameNotFoundException e)
{
// If Twitter app is not installed, start browser.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/AndroTesteur")));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With