I have been working on getting the facebook practice apps working and I cannot for the life of me figure out why I cannot reference the LoginButton found in the Facebook SDK
If you are use android studio then its clear documentation here,
Use facebook with fragment Tutorial
User facebook without fragment
Step 1 :Create java file MyApplication.java inside your package.
Tutorial
and copu myApplicatyon.java
Step 2 :setup androidmenufest.xml
Step 3 : Init inside activity where you are looking for init Login Button
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
callbackManager = CallbackManager.Factory.create();
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_auth_login);
//Init Elements
etEmail = (EditText) findViewById(R.id.etEmail);
etPassword = (EditText) findViewById(R.id.etPassword);
validator = new Validator(this);
validator.setValidationListener(this);
serverConnection = new ServerConnection();
//Faceboo login init
loginButton = (LoginButton) findViewById(R.id.btnFbLogin);
loginButton.setReadPermissions(Arrays.asList("public_profile","email","user_photos"));
// Other app specific specialization
// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
Profile profile = Profile.getCurrentProfile();
Log.v("profile.getName:",profile.getName());
}
@Override
public void onCancel() {
// App code
}
@Override
public void onError(FacebookException exception) {
// App code
}
});
}