从Android应用程序打开Twitter应用程序用户配置文件

从Android应用程序打开Twitter应用程序用户配置文件,android,twitter,Android,Twitter,我可以启动Twitter应用程序(如果手机上有),但我找不到如何自动显示特定的用户配置文件 类似的内容适用于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

我可以启动Twitter应用程序(如果手机上有),但我找不到如何自动显示特定的用户配置文件

类似的内容适用于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");
以下是Facebook的方式:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/USER_ID"));
startActivity(intent);
当我启动Twitter应用程序时,应该有同样的解决方案吗

Intent intent = getPackageManager().getLaunchIntentForPackage("com.twitter.android");
intent.putExtra("WHAT_TO_PUT_HERE?", "USER_ID");
startActivity(intent);

这与新的Twitter应用程序配合得很好。@Baptiste Costa提供的解决方案对我不起作用。

这是一个非常老的问题,我想解释一下。如果失败的话,我已经使用用户id或用户名完成了

Intent intent;
try {
    // Check if the Twitter app is installed on the phone.
    context.getPackageManager().getPackageInfo("com.twitter.android", 0);

    intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?user_id=813679215195410432"));
} catch (Exception e) {
    intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/LynxMods"));
}
context.startActivity(intent);

确认;但是:getPackageManager().getPackageInfo(“com.twitter.android”,0);+对NameNotFoundException进行try/catch仍然有助于回退webapp(我的用例是将意图传递给通知,所以我需要提前知道什么会起作用-这是最简单的选择)。这应该是我们的with
@
?@JonasB它没有“@”标志这是在运行catch的模拟器上工作的。在我将用户名改为screen\u name,intentTW.putExtra(“screen\u name”,twitterProfile)后,我的设备安装了twitter应用程序,并且运行良好;
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)));
}
Intent intent;
try {
    // Check if the Twitter app is installed on the phone.
    context.getPackageManager().getPackageInfo("com.twitter.android", 0);

    intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?user_id=813679215195410432"));
} catch (Exception e) {
    intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/LynxMods"));
}
context.startActivity(intent);