【问题标题】:Open Facebook User Profile Android打开 Facebook 用户配置文件 Android
【发布时间】:2015-01-02 17:25:03
【问题描述】:

当我尝试通过官方 Facebook 应用打开 Facebook 个人资料时,出现此错误:加载传记时出错,内容不可用。 我尝试了很多代码,但没有。仅当设备上未安装 Facebook 应用程序时,浏览器才能正常工作。 这是当前代码:

try
 {
   Intent followIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/"+id_facebook));
                                                            startActivity(followIntent);
   final Handler handler = new Handler();
   handler.postDelayed(new Runnable()
   {
     @Override
     public void run() {
         Intent followIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/"+id_facebook));
         startActivity(followIntent);
     }
   }, 1000 * 2);
 }
catch (Exception e)
 {
   startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/"+id_facebook)));
   String errorMessage = (e.getMessage()==null)?"Message is empty":e.getMessage();
   Log.e("Unlock_ScreenActivity:FacebookAppNotFound" ,errorMessage);
 }

更新:

当我放弃只放 https URI 时,Android 让我在 Facebook APP 和浏览器之间进行选择,我喜欢它!所以我的问题得到了回答=D

【问题讨论】:

  • 你的应用有适当的权限吗?
  • 没有办法做到这一点。
  • 在 Facebook 的开发者页面或 AndroidManifest 中?在 AndroidManifest 我拥有所有的propers权限。

标签: android facebook


【解决方案1】:

我在当天遇到了类似的问题,发现当我尝试使用与您相同的方法时,它仅在我想查看自己的个人资料(或 Facebook 应用程序中当前登录的用户)时才有效但是每当我试图显示别人的 facebook 页面时,我最终都遇到了这个答案:

https://stackoverflow.com/a/24547437/1879664

长话短说,它不再可能,到目前为止唯一的解决方法是让 facebook 像您提到的那样在 facebook 中加载网页,但不同的是,如果用户无法选择,则无需强制应用程序或已选择其他浏览器作为默认应用程序,您将无法再通过 facebook 打开该页面。使用此代码,您可以确保它始终使用 facebook 应用程序打开该页面(如果已安装,或者将使用您的默认浏览器加载)。这是我在应用中使用的代码:

try {

        mActivity.getPackageManager().getPackageInfo("com.facebook.katana", 0);
            String url = "https://www.facebook.com/profile.php?id=USER_ID"

            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href="+url));
        }
        mActivity.startActivity(intent);

   } catch (Exception e) {

       Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/profile.php?id=USER_ID"));
       mActivity.startActivity(intent);

       e.printStackTrace();

   }

【讨论】:

  • 它有效,但我将此行更改为:String url = "https://www.facebook.com/"+idFacebook;
猜你喜欢
  • 2011-05-10
  • 2019-10-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-15
  • 2016-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多