0

I would like to open the Facebook app and go directly to a Facebook page when the user presses a button in my app.

How do I do that using the official Facebook SDK?

So far, all the solutions I've seen is fairly hacky, checking to see if the FB app is installed using Package Manager or something. This might become an issue in the future, given the precedent of Package Visibility.

Another solution relies on a list of unofficial URIs sourced from the decompiled Facebook APK, which can break at any time.

Aloha
  • 864
  • 18
  • 40

1 Answers1

-1

I have tried this code. It is work to open the facebook application 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);
}

if you want to intent to the specific profile / Group / Page , you need to change the code fb://profile --> "fb://group" / "fb://page"

anonymous
  • 228
  • 1
  • 11