Open Facebook page from Android app?

前端 未结 26 3127
被撕碎了的回忆
被撕碎了的回忆 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:49

    open fb on button click event without using facebook sdk

     Intent FBIntent = new Intent(Intent.ACTION_SEND);
        FBIntent.setType("text/plain");
        FBIntent.setPackage("com.facebook.katana");
        FBIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
        try {
            context.startActivity(FBIntent);
        } catch (android.content.ActivityNotFoundException ex) {
            Toast.makeText(context, "Facebook have not been installed.", Toast.LENGTH_SHORT).show( );
        }
    
    0 讨论(0)
  • 2020-11-22 07:50

    For Facebook page:

    try {
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/" + pageId));
    } catch (Exception e) {
        intent =  new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + pageId));
    }
    

    For Facebook profile:

    try {
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + profileId));
    } catch (Exception e) {
        intent =  new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + profileId));
    }
    

    ...because none of the answers points out the difference

    Both tested with Facebook v.27.0.0.24.15 and Android 5.0.1 on Nexus 4

    0 讨论(0)
提交回复
热议问题