Project configuration

Now, in the manifest of our project, we can add the following code changes. 

Open the string.xml file and add the Facebook app ID and Facebook protocol scheme ID:

Goto /app/res/values/strings.xml

//Add the following strings
<string name="facebook_application_id">470058756728712</string> <string name="fb_login_protocol_scheme">fb470058756728712</string>

Since we already have added internet permissions, we need not worry about it but if you haven't added internet permissions, please do so now:

<uses-permission android:name="android.permission.INTERNET"/>

We need to add the metadata elements inside the manifest and within the application tag scope:

<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_application_id"/>

<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>

Now, add the following code inside the getAuthProviderList method:


private List<AuthUI.IdpConfig> getAuthProviderList() {
List<AuthUI.IdpConfig> providers = new ArrayList<>();
providers.add(
new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build());
providers.add(new
AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build());
providers.add(new
AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build())
;

return providers;
}

If there is no Facebook application installed in the device, it will prompt a webview with a Facebook login. The FirebaseUser object allows developers to access the profile photograph, name, email address, and other profile details.