0

这是我用于调用应用程序的完整代码。它列出了所有可以响应该对象的应用程序。我怎样才能只调用 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"));
}

}

4

1 回答 1

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")));
           }
于 2013-11-03T13:05:44.510 回答