【发布时间】:2012-07-04 21:09:43
【问题描述】:
我正在开发一个需要集成不同社交网络的社交功能的应用程序:Facebook、Twitter、Google+。
目前,在 Facebook 和 Twitter 中,如果用户有本地应用程序,我会被识别,如果有,我会打开它并向他展示我的粉丝页面。
对于 Twitter,我使用以下代码:
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,下一个代码:
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+ 做同样的事情。我看到我可以用下一个网址https://plus.google.com/MY_PAGE_ID/ 浏览到我的粉丝页面,但它一直问我是用 Google+ 应用程序还是用浏览器打开它,我希望他会用应用程序自动打开它,无需询问用户。
有没有简单的方法来做到这一点? 谢谢。
【问题讨论】:
标签: android facebook twitter android-intent google-plus