我如何在Android上调用facebook应用程序?

时间:2013-11-03 12:57:16

标签: android facebook

这是我用来调用app的完整代码。它列出了所有可以响应对象的应用程序。我怎么才能只打电话给Facebook应用程序?感谢

公共类MainActivity扩展了Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Intent i = new Intent(android.content.Intent.ACTION_SEND);
    i.setType("image/jpg");
    i.putExtra(Intent.EXTRA_SUBJECT, "Subject...");
    i.putExtra(Intent.EXTRA_TEXT, "Text...");
    startActivity(Intent.createChooser(i, "Apps that can respond to this"));
}

}

1 个答案:

答案 0 :(得分:0)

        try 
           { // check if Facebook app is installed on the phone 
            context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/profile_id")));
           } 
       catch (Exception e) 
           { //open the Facebook profile of the user in the web browser
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/username")));
           }