2013-11-03 70 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"))); 
      } 
相關問題