名称
URL schema
首页
fb://feed

前台好友

fb://notifications

照片

fb://albums

id搜索好友

fb://page/uid —(or)— fb://profile/uid

设置

fb://account_settings

好友

fb://friends

我的所有好友

fb://faceweb/f?href=%2Ffriends%2Fcenter%2Ffriends%2F

搜索名字

fb://search

推荐好友

fb://friends/center —(or)— fb://findfriends/browser

搜索好友的好友

fb://profile/uid/friends

搜索好友的推荐好友

fb://profile/uid/friends/friends

关闭通知

fb://notification_settings_push_and_sounds

进入Messenger(Facebook里的)

fb://faceweb/f?href=%2Fmessages?src=fb4a

朋友圈和艾特关闭设置

fb://faceweb/f?href=%2Fprivacy%2Ftouch%2Ftimeline_and_tagging

语言

fb://language_switch

退出帐号

fb://logged_out_push_interstitial

资料修改

fb://profile_edit

生日

fb://birthdays

公开

fb://faceweb/f?href=%2Fprivacy

小组1

fb://faceweb/f?href=/groups

小组2

fb://groups/createtab

小组3

fb://groups/discover

小组4

fb://groups/discover/categories

不知名协议

fb://friends/new_user_promotion

fb://online

fb://requests

fb://events

fb://places

fb://birthdays

fb://notes

fb://places

fb://groups

fb://albums

fb://notifications

fb://group/id

 

参考代码

//应用内跳转指定账号
val url = “https://www.facebook.com/Bouti.thai/”
try {
getPackageManager().getPackageInfo(“com.facebook.katana”, 0)
val uri = Uri.parse(“fb://facewebmodal/f?href=” + url)
startActivity(Intent(Intent.ACTION_VIEW, uri))
} catch (e: Exception) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
}

//url为facebook账号的直达连接 当手机未安装facebook app时走catch内容, 通过跳转手机浏览器显示facebook账号

startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(“fb://page/id_here”)))

//“id_here”应该是账号id,该方法是否可用还未知, 仅供参考

//启动facebook,如果已经启动,就切换到前台

fun startFacebook(context: Context) {
val pkgName = “com.facebook.katana”
var intent=context.packageManager.getLaunchIntentForPackage(pkgName);
if (intent==null) {
intent = Intent()
intent.action = “android.intent.action.VIEW”
// 打开url
val content_url = Uri.parse(“http://facebook.com/”)
intent.data = content_url
context.startActivity(intent)

} else {
/* intent.flags =
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED or Intent.FLAG_ACTIVITY_CLEAR_TOP*/
context.startActivity(intent)
}

}

//打开指定页面
//个人主页参数:https://www.facebook.com/profile.php?id=xxx

fun startFaceBookWithUrl(context: Context,url:String){
val install=AppUtils.isAppInstalled(“com.facebook.katana”)
val intent = Intent()
intent.action = “android.intent.action.VIEW”;

val facebookUrl=if(!install){
url
}else{
getFacebookDetailURL(context,url)
}
intent.data = Uri.parse(facebookUrl)

context.startActivity(intent)
}

//直接链接

fun getFacebookDetailURL(context: Context,url:String): String? {
val packageManager = context.packageManager
try {
val versionCode = packageManager.getPackageInfo(“com.facebook.katana”, 0).versionCode
if (versionCode >= 3002850) { //newer versions of fb app
return “fb://facewebmodal/f?href=$url”
}
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
}
return url
}

 



————————————————
版权声明:本文为CSDN博主「鸿图大展的我」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_48141487/article/details/134191835

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注