Подтвердить что ты не робот

Открыть профиль пользователя приложения Twitter из приложения Android

Я могу запустить приложение 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);
4b9b3361

Ответ 1

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

Это отлично работает с новым приложением Twitter. Решение, предоставленное @Baptiste Costa, не помогло мне.

Ответ 2

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