如果安装了Facebook应用程序,则Android打开Facebook页面链接, [英] Android open facebook page link in facebook app if installed ,

查看:219
本文介绍了如果安装了Facebook应用程序,则Android打开Facebook页面链接,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Facebook App中打开Facebook页面链接(如果已安装),以及是否未安装该应用,请在android的默认浏览器中打开

how to open Facebook page link in Facebook App if installed , and if the app is not installed open in default browser in android ??

我尝试了此代码,但无法正常工作?

i tried this code but its not working ??

     Face.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = null;
            String Facebook = dbList.get(0).getFacebook().toString();
            try {
                // get the Twitter app if possible
                getPackageManager().getPackageInfo("com.facebook.android", 0);
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" +Facebook));
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            } catch (Exception e) {
                // no Twitter app, revert to browser
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/?hl=en"));
            }
            startActivity(intent);
        }
    });

推荐答案

使用此代码,您可以打开用户个人资料

public static void opneFacebookProfile(Activity activity, String id) {
        Intent facebookIntent = new Intent(Intent.ACTION_VIEW);
        String facebookUrl = getFacebookPageURL(activity, id);
        facebookIntent.setData(Uri.parse(facebookUrl));
        activity.startActivity(facebookIntent);
    }

这篇关于如果安装了Facebook应用程序,则Android打开Facebook页面链接,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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