我正在尝试使用 URI 方案打开 Facebook 并具有预定义的文本。
我无法实现我想要的,我只能打开 Facebook 但没有预定义的文本。
我尝试了以下方法:
fb://publish/profile/me?text=test
fb://publish/?text=#test#
fb://post/?message=test
fb://composer?text=test
知道如何实现吗?(如果重要的话,我正在使用nexus 5)
我正在尝试使用 URI 方案打开 Facebook 并具有预定义的文本。
我无法实现我想要的,我只能打开 Facebook 但没有预定义的文本。
我尝试了以下方法:
fb://publish/profile/me?text=test
fb://publish/?text=#test#
fb://post/?message=test
fb://composer?text=test
知道如何实现吗?(如果重要的话,我正在使用nexus 5)
我还没有研究过,但是让我尝试帮助您解决这个问题,我发现的是
Facebook 自定义 URL 方案。
这就是我发现的感谢Robert Strojan
fb://profile – Open Facebook app to the user’s profile
fb://friends – Open Facebook app to the friends list
fb://notifications – Open Facebook app to the notifications list (NOTE: there appears to be a bug with this URL. The Notifications page opens. However, it’s not possible to navigate to anywhere else in the Facebook app)
fb://feed – Open Facebook app to the News Feed
fb://events – Open Facebook app to the Events page
fb://requests – Open Facebook app to the Requests list
fb://notes- Open Facebook app to the Notes page
fb://albums – - Open Facebook app to Photo Albums list
String facebookUrl = "https://www.facebook.com/rdcworld";
try {
int versionCode = getPackageManager().getPackageInfo("com.facebook.katana", 0).versionCode;
if (versionCode >= 3002850) {
Uri uri = Uri.parse("fb://facewebmodal/f?href=" + facebookUrl);
startActivity(new Intent(Intent.ACTION_VIEW, uri));;
} else {
// open the Facebook app using the old method (fb://profile/id or fb://pro
}
} catch (PackageManager.NameNotFoundException e) {
// Facebook is not installed. Open the browser
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(facebookUrl));
}