如何从我的应用程序创建到Facebook页面的意图? [英] How do I create a intent from my app to facebook page?

查看:58
本文介绍了如何从我的应用程序创建到Facebook页面的意图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个已成定局的问题,我想我已经可以轻松找到答案了,但是我发现的答案很旧,无法解决.如何从我的应用程序创建到Facebook页面的意图?如果打开了Facebook应用,我想这样做,否则请浏览器

It seemed a foregone question and I thought I could easily find an answer already, but the answers I found are very old and they do not work. How do I create a intent from my app to facebook page? I would like that if there is open the Facebook app, otherwise the browser

到目前为止,最好的解决方案是Rishav Singla的解决方案:

Up to now the best SOLUTION is that of Rishav Singla:

public static Intent getOpenFacebookIntent(Context context) {

    try {
        context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
        return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/<id_here>"));
    } catch (Exception e) {
        return new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://www.facebook.com/<user_name_here>"));
    }
}

使用:

startActivity(getOpenFacebookIntent(getApplicationContext()));

...在attesa di altre soluzioni中

... in attesa di altre soluzioni

推荐答案

使用URL到Facebook在浏览器中打开

Use URL to facebook to Open it in browser

    String url = "https://www.facebook.com/ZambianWatchdog/";
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    startActivity(i);

这篇关于如何从我的应用程序创建到Facebook页面的意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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