Facebook官方Android SDK-如何打开页面



当用户按下我的应用程序中的按钮时,我想打开Facebook应用程序并直接转到Facebook页面。

我如何使用官方的Facebook SDK做到这一点?

到目前为止,我看到的所有解决方案都相当粗糙,检查FB应用程序是否使用Package Manager或其他软件安装。考虑到包可见性的先例,这可能在未来成为一个问题。

另一个解决方案依赖于来自反编译的Facebook APK的非官方URI列表,这些URI可以随时中断。

我已经尝试过这个代码。打开facebook应用程序是工作https://stackoverflow.com/a/52480045/14215175

try
{
Intent followIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/<your profile_id>"));
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/<your profile_id>"));
startActivity(followIntent);
}
}, 1000 * 2);
}
catch (Exception e)
{
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/<user_name>")));
String errorMessage = (e.getMessage()==null)?"Message is empty":e.getMessage();
Log.e("Unlock_ScreenActivity:FacebookAppNotFound" ,errorMessage);
}

如果要使用特定的配置文件/组/页面,则需要更改代码fb://profile-->quot;fb://group"/"fb://page";

最新更新