udenfox udenfox - 1 month ago 18
Android Question

Progressbar disappears in battery saver mode (Android 5.x)?

I noticed that when the Battery saver mode is enabled (by the user or automatically) in Android 5.x - ProgressBars in application just disappear.

No animation, no static progressbar widget - just empty place.

How to prevent that? I understand when Battery saver disables some system animations, but progressbars is actually an important part of the application UI.

Just in case - code that implements ProgressBar Layout:

<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/refresh_bar"
android:layout_alignParentTop="true"
android:indeterminate="true"
android:visibility="gone"
android:layout_marginTop="@dimen/progress_bar_top_margin" />


And how it's implemented in my fragment class:

public class FeedFragment extends Fragment {
...
// Progressbar to show refreshing state
private ProgressBar mRefreshBar;
...

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View v = inflater.inflate(R.layout.fragment_feed, container, false);
...
// Initialize and locate Refreshing progress bar
mRefreshBar = (ProgressBar) v.findViewById(R.id.refresh_bar);
...
mRefreshBar.setVisibility(View.VISIBLE);
...
}
...
}


Also, I facing that problem with all progress bars in application, not only with this one.
When Battery saver mode disabled - all works just fine.

Answer

When Battery saver mode is enabled, every app on the device have the same issue.

Because Battery saver mode extends the battery life so that you can use the phone until you have a chance to charge it. It happens to every application. So don't worry.

How to prevent that?

By disabling Battery saver mode in Settings and then rebooting the device. Or you can request permission from the user to disable it.