0

here is the complete code I use for calling app. And it list all the apps that can respond to the object. How can I call only Facebook app ? Thanks

public class MainActivity extends 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"));
}

}

Adam
  • 7
  • 2

1 Answers1

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")));
           }
Swayam
  • 16,294
  • 14
  • 64
  • 102