views:

101

answers:

1

hi

how to add facebook Application in my Android Application .i want to add a image button. when the user clicks on this button it should go to the facebook page .where the user can sign in .please anyone help me to solve this problem..please send me a source code of the App

+1  A: 

You can add an OnClickListener to your button, and if the button is clicked start a browser via an intent that points to facebook. This would only let the user go to facebook and do whatever she wants there, if you want to interact with some facebook api you have to go another route.

button.setOnClickListener(new OnClickListener() {
  public void onClick(View view) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://facebook.com"));
    startActivity(intent);
  }
});

Disclaimer The code is not tested completly but it must be something like that. If you spot an error feel free to correct it.

Janusz