I was looking for some way to launch Twitter app and open a specified page from my application, without webview. I found the solution for Facebook here: Opening facebook app on specified profile page
I need something similar.
EDIT I just found a solution:
try {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("twitter://user?screen_name=[user_name]"));
startActivity(intent);
} catch (Exception e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://twitter.com/#!/[user_name]")));
}
This worked for me:
twitter://user?user_id=id_num
To know the ID: http://www.idfromuser.com/
or with checking if there's a google map app on device and if not open the location in browser
Just try this code snippet. It will help you.
My answer builds on top of the widely-accepted answers from fg.radigales and Harry. If the user has Twitter installed but disabled (for example by using App Quarantine), this method will not work. The intent for the Twitter app will be selected but it will not be able to process it as it is disabled.
Instead of:
You can use the following to decide what to do:
Based on fg.radigales answer, this is what I used to launch the app if possible, but fall back to the browser otherwise:
UPDATE
Added
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
to fix an issue where twitter was opening inside my app instead of as a new activity.Open page on Twitter app from other app using Android in 2 Steps:
1.Just paste the below code (on button click or anywhere you need)
2.
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?user_id=USER_ID"));
To get USER_ID just write username http://gettwitterid.com/ and get Twitter User ID in there
Reference: https://solutionspirit.com/open-page-twitter-application-android/
Hope it will Help :)