Opening facebook app on specified profile page

后端 未结 7 1066
温柔的废话
温柔的废话 2020-12-24 14:20

I\'m trying to use some code from SO but it fails:

Those are uri\'s supposed to open the right section of the app.

facebook://facebook.com/info?user=         


        
7条回答
  •  一生所求
    2020-12-24 15:07

    There are so many question about this but this code is worked for me.Facebook changed there policy so for more detail please check this Facebook official GRAPH API EXPLORER PAGE

    Intent intent = null;
        try {
            getPackageManager().getPackageInfo("com.facebook.katana", 0);
            String url = "https://www.facebook.com/"+idFacebook;
            intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href="+url));
        } catch (Exception e) {
            // no Facebook app, revert to browser
            String url = "https://facebook.com/"+idFacebook;
            intent = new Intent(Intent.ACTION_VIEW);
            intent .setData(Uri.parse(url));
        }
        this.startActivity(intent);
    

提交回复
热议问题