Search code examples
androidfacebookfacebook-android-sdk

Android facebook sdk 3.0 login by custom button


Android facebook sdk 3.0 login by custom button. I dont want to use fragment . Just click a button then facebook login fetch the user name ,email,uid and the access token.

If facebook login in a dialog box there is no problem.


Solution

  • 1 - add facebook login activity in your AndroidManifest.xml

     <activity android:name="com.facebook.LoginActivity" android:screenOrientation="portrait"></activity>
    

    2 - Button click event

    Intent  i = new Intent(this,com.facebook.LoginActivity.class);
    startActivity(i);
    

    This will open facebook login activity.

    I recommend you this material about facebook Session: https://developers.facebook.com/docs/reference/android/3.0/Session/

    Session can be managed by UiLifecycleHelper