2013-11-03 67 views
0

这里是我用于调用应用程序的完整代码。它列出了所有可以响应该对象的应用程序。我怎样才能拨打Facebook应用程序?由于我怎样才能在Android上调用Facebook应用程序?

公共类MainActivity扩展活动{

@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")); 
} 

}

回答

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"))); 
      } 
相关问题