user8550883
user8550883

Reputation: 83

Open twitter account from android app

I am trying to open twitter account from my android application by using the following code. But it fails and getting this message.

cannot get users at this time please try again later

Code

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);
}

Upvotes: 3

Views: 1393

Answers (1)

shmakova
shmakova

Reputation: 6426

Try to use this (change user_id to screen_name):

"twitter://user?screen_name=" + mTwitterHandle

Upvotes: 3

Related Questions