I am writing a code for facebook integration.I created App Id and also imported facebook sdk.I put a button on my main activity which will open up a facebook dialog asking l
Please go through this https://github.com/facebook/facebook-android-sdk/ and https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/
private OnClickListener loginButtonListener = new OnClickListener() {
public void onClick(View v) {
if (!mFacebook.isSessionValid()) {
Toast.makeText(Login.this, "Authorizing", Toast.LENGTH_SHORT)
.show();
mFacebook.authorize(Login.this, new String[] { "" },
new LoginDialogListener());
} else {
Toast.makeText(Login.this, "Has valid session",
Toast.LENGTH_SHORT).show();
try {
JSONObject json = Util.parseJson(mFacebook.request("me"));
String facebookID = json.getString("id");
String firstName = json.getString("first_name");
String lastName = json.getString("last_name");
Toast.makeText(
Login.this,
"You already have a valid session, " + firstName
+ " " + lastName
+ ". No need to re-authorize.",
Toast.LENGTH_SHORT).show();
} catch (Exception error) {
Toast.makeText(Login.this, error.toString(),
Toast.LENGTH_SHORT).show();
} catch (FacebookError error) {
Toast.makeText(Login.this, error.toString(),
Toast.LENGTH_SHORT).show();
}
}
}
};