Search code examples
androidprogress-barandroid-progressbarfacebook-sdk-4.0

How to remove the ProgressBar from Facebook login sdk


By implementing the Facebook Login with android I need to send the token tom my back-end server, so I was wondering if I could remove the Progress bar and create my own progress, dispose after getting the Facebook Token and sending to my server. It appears when I call :

LoginManager.getInstance().logInWithReadPermissions(Login.this,Arrays.asList("email"));

Solution

  • You can remove the Facebook login ProgressBar like this:

    In values/styles.xml add the following style:

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

    In values-v21/styles.xml add the following style:

    <style name="Translucent" parent="Translucent.Base">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>
    

    Then, in your AndroidManifest.xml override the theme of the FacebookActivity:

    <manifest
      ...
      xmlns:tools="http://schemas.android.com/tools"
    >
    
    ...
    
    <activity
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name"
        android:theme="@style/Translucent"
        tools:replace="android:theme"
    />
    

    Now you will not see the Facebook progress bar and you can draw your own :)