我正在尝试使用URI方案打开Facebook并拥有预定义的文本 我无法实现我想要的,我只能打开Facebook但没有预定义的文本。
我尝试了以下内容:
fb://publish/profile/me?text=test
fb://publish/?text=#test#
fb://post/?message=test
fb://composer?text=test
任何想法如何实现它? (如果重要,我正在使用nexus 5)
答案 0 :(得分:4)
答案 1 :(得分:3)
我没有参与其中,但是让我试着帮助你解决这个问题
Facebook自定义网址方案。
这是我发现的感谢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));
}