Login for Android Devices

In order to better support login on TVs, the Facebook SDK for Android has built-in support for Facebook Login for Devices.

Step 1. Use DeviceLoginButton or DeviceLoginManager

Use the Device Login Button to provide a login button that triggers the Login for Devices flow.

DeviceLoginButton button = (DeviceLoginButton)view.findViewById(R.id.login_button);

Or programmatically trigger the Login for Devices flow using a Device Login Manager.

DeviceLoginManager loginManager = new DeviceLoginManager();

Both DeviceLoginButton and DeviceLoginManager provide a setDeviceRedirectUri setter. You can pass in the URI the person will be redirected to after completing the login at facebook.com/device. The URI must be a valid OAuth Redirect URI as configured in your App Settings -> Advanced.

When logging in, you should now see a dialog similar to the following.

Smart Login

Smart Login was introduced with v4.17.0 of the Facebook SDK and makes the login experience even easier by communicating the code directly to the Facebook app on the same wireless network. No API changes are needed to take advantage of this feature.

Step 2. Completing the Login

Read the Facebook Login for Android guide to understand how to use the access token.