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.
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.
1- add facebook login activity in your AndroidManifest.xml
<activity android:name="com.facebook.LoginActivity" android:screenOrientation="portrait"></activity>
2- on button click
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
I realize this is an old thread but I was having a similar issue and the other answer did not work for me. I wanted to have my own custom button have the same functionality as the built in Login Button.
The first step was to include the built in facebook button in my xml file but set its visibility to "gone" so it cannot be seen by the user.
<com.facebook.widget.LoginButton
android:id="@+id/authButton"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
/>
In my main activity, I then defined the hidden facebook button and the button I wanted to use
fbLoginButton = (Button) findViewById(R.id.authButton); //built in facebook button
customButton = (Button) findViewById(R.id.customButton); //my custom button
Then in an onClickListener for the custom button, I used the ".performClick" method on the facebook button
customButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fbLoginButton.performClick();
}
});
This works like a charm for me. Hopefully this can help somebody.