jmhostalet jmhostalet - 6 months ago 320
Android Question

Android: How to hide progress circle in Facebook login

I am using this method to perform a Facebook login without using the fb button Facebook authentication without login button

It's working fine, but a progress bar with black background is shown during fb login, I guess from activity com.facebook.LoginActivity

How can I avoid displaying that activity?, I just want to show my own progress from my app activity during login in com.facebook.LoginActivity

VM4 VM4
Answer

I had the same problem with facebook sdk 4.x. When I click the facebook login button the Facebook Activity appears translucent but it shows a progress bar. Luckily we can disable this progress bar in the theme. So the Facebook Activity is declared as

<activity
    android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />

All we have to do is create a style that inherits from Theme.Translucent.NoTitleBar and hides the progress bar:

<style name="FullyTranslucent" parent="android:Theme.Translucent.NoTitleBar">
    <item name="android:progressBarStyle">@style/InvisibleProgress</item>
</style>

<style name="InvisibleProgress">
    <item name="android:visibility">gone</item>
</style>

Now set the theme of the activity to our new theme:

<activity
    android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name"
    android:theme="@style/FullyTranslucent" />

Voila! The ProgressBar before login is gone.