从其他应用程序打开 Facebook、Twitter 和 Google Plus 应用程序中的页面 - Android [英] Open page in Facebook,Twitter and Google Plus app from other app - Android

查看:33
本文介绍了从其他应用程序打开 Facebook、Twitter 和 Google Plus 应用程序中的页面 - Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,我需要在该应用程序中集成不同社交网络的社交功能:Facebook、Twitter、Google+.

I'm working on an application where I need to integrate the social functionality of the different social networks: Facebook, Twitter, Google+.

目前,在 Facebook 和 Twitter 上,我可以识别用户是否有本机应用程序,如果有,我会打开它并向他展示我的粉丝页面.

For now, in Facebook and Twitter i'm recognized if the user has a native application and if he does, I'm opening it and show him my fan page.

对于 Twitter,我使用下一个代码:

For Twitter I use the next code:

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

对于 Facebook,下一个代码:

And for Facebook the next code:

try{

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + PROFILE_FACEBOOK_APP_ID));
startActivity(intent);

}catch(Exception e){

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/UserNamePage")));
}

现在我想为 Google+ 做同样的事情.我看到我可以使用下一个 URL https://plus.google.com/MY_PAGE_ID/ 浏览到我的粉丝页面,但它一直问我是要使用 Google+ 应用程序打开它还是使用浏览器,我希望他会自动使用应用程序打开它,而无需询问用户.

Now I want to do the same thing for Google+. I saw that I can browse to my fan page with the next Url https://plus.google.com/MY_PAGE_ID/, but it keep asking me if I want to open it with Google+ application or with the browser, and I want that he will open it with the application automatically, without asking the user.

有没有简单的方法可以做到这一点?谢谢.

Is there a simple way to do this? Thanks.

推荐答案

找到解决方案:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.google.android.apps.plus",
"com.google.android.apps.plus.phone.UrlGatewayActivity");
intent.putExtra("customAppUri", "FAN_PAGE_ID");
startActivity(intent);

这篇关于从其他应用程序打开 Facebook、Twitter 和 Google Plus 应用程序中的页面 - Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆