gpt4 book ai didi

android - 打开 Facebook 用户个人资料 Android

转载 作者:太空宇宙 更新时间:2023-11-03 13:20:58 26 4
gpt4 key购买 nike

当我尝试通过官方 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 应用程序中的当前登录用户)时才有效但每当我试图展示别人的 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();

}

关于android - 打开 Facebook 用户个人资料 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27746017/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com