从Android应用程序打开Twitter账户

3

我正试图通过以下代码从我的Android应用程序打开Twitter帐户。但是它失败并得到这个消息。

无法获取用户,请稍后重试

代码

public static void openTwitterHandle(String mTwitterHandle, FragmentActivity activity) {
    Intent intent = null;
    try {


        activity.getPackageManager().getPackageInfo("com.twitter.android", 0);
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?user_id=" + mTwitterHandle));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    } catch (Exception e) {
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/" + mTwitterHandle));
    }
    activity.startActivity(intent);
}
1个回答

3
尝试使用以下代码(将user_id更改为screen_name):
"twitter://user?screen_name=" + mTwitterHandle

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接