How to do Facebook Login with Custom Button Android

In my previous Facebook Post(http://androidammy.blogspot.in/2015/07/facebooklogin1.html). I write how to use Facebook default button to login with Facebook.

In this blog I am writing about how we can use facebook login functionality from android widget like Button/TextView/ImageView. All the steps are same as last facebook login post. This blog describe that  how to create instance of CallBackManager and LoginManager and how to call Login from click listener.

1.  Create Instance of LoginManager and CallbackManager.

com.facebook.login.LoginManager fbLoginManager;
        
        fbLoginManager = com.facebook.login.LoginManager.getInstance();
        CallbackManager callbackManager = CallbackManager.Factory.create();
        mFbLoginManager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
              // here write code When Login successfully 
            }

            @Override
            public void onCancel() {
                
            }

            @Override
            public void onError(FacebookException e) {
                // here write code when get error
            }
        });
2. Call loginWithReadPermission method of LoginManager class from clickListener of android widget, Like 
    buttonFbLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mFbLoginManager.logInWithReadPermissions(LoginActivity.this, Arrays.asList("email", "public_profile", "user_birthday"));
            }
        });

All Done.
Happy Coding. 

Comments

  1. Facebook has no operating system or browser to guarantee its presence on mobile phones The company depends on apps and the mobile Web. www.facebook.com login

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. The blog has been written very well the writer is well skilled and also experienced, for any information about Gmail the user should visit:
    visit site

    ReplyDelete
  5. The blog has been written very well the writer is well skilled and also experienced, for any information about Gmail the user should visit:
    Facebook bellen

    ReplyDelete
  6. Hey friend, it is very well written article, thank you for the valuable and useful information you provide in this post. Keep up the good work! Happy ig captions

    ReplyDelete
  7. This is useful information. Thank you for your post. Really helpful.
    Facebook bellen

    ReplyDelete

Post a Comment

Popular posts from this blog

How to change the color of Hamburger icon in Toolbar Android

How to combine two Bitmap in Android