Open Facebook page from Android app?

前端 未结 26 3522
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 07:03

from my Android app, I would like to open a link to a Facebook profile in the official Facebook app (if the app is installed, of course). For iPhone, there exists the

26条回答
  •  庸人自扰
    2020-11-22 07:36

    To launch facebook page from your app, let urlString = "fb://page/your_fb_page_id"

    To launch facebook messenger let urlString = "fb-messenger://user/your_fb_page_id"

    FB page id is usually numeric. To get it, goto Find My FB ID input your profile url, something like www.facebook.com/edgedevstudio then click "Find Numberic ID".

    Voila, you now have your fb numeric id. replace "your_fb_page_id" with the generated Numeric ID

     val intent = Intent(Intent.ACTION_VIEW, Uri.parse(urlString))
     if (intent.resolveActivity(packageManager) != null) //check if app is available to handle the implicit intent
     startActivity(intent)
    

提交回复
热议问题