You can open the facebook app on button click as follows:-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startNewActivity("com.facebook.katana");
}
});
}
public void startNewActivity( String packageName)
{
Intent intent = MainActivity.this.getPackageManager().getLaunchIntentForPackage(packageName);
if (intent != null)
{
// we found the activity
// now start the activity
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
else
{
// bring user to the market
// or let them choose an app?
intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id="+packageName));
startActivity(intent);
}
}