Hardeep Singh Hardeep Singh - 10 months ago 108
Android Question

Android Facebook login without Facebook login button

I want login with facebook without using Facebook Login Button. so i applied click event on default android button.

But i got error

cannot resolve method logInWithReadPermissions(..)..

here is my code. Any help will appreciated

btnFBLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "email"));// here giving error can not resolve method


You are currently passing reference of button

But you need to pass reference of Activity

Please use the below code that might help you.

LoginManager.getInstance().logInWithReadPermissions(LoginActivity.this, Arrays.asList("public_profile", "email"));