Wednesday, 15 February 2023

E/PhoneWindows: "Horizontal progress bar not located in current window decor"

My app used to display a progress bar at the top, from Android 2.2 to 4.3 (API 8-18), but now when adapting it to Android 8-13 (API 26-33), I no longer see it.

Instead, I am getting this error message in the Debug log:

E/PhoneWindow: Horizontal progress bar not located in current window decor

Googling this error message, only yields PhoneWindow.java source code, logging it 6 times as in:

    final int features = getLocalFeatures();
    if (value == PROGRESS_VISIBILITY_ON) {
        if ((features & (1 << FEATURE_PROGRESS)) != 0) {
            if (horizontalProgressBar != null) {
                int level = horizontalProgressBar.getProgress();
                int visibility = (horizontalProgressBar.isIndeterminate() || level < 10000) ?
                        View.VISIBLE : View.INVISIBLE;
                horizontalProgressBar.setVisibility(visibility);
            } else {
                Log.e(TAG, "Horizontal progress bar not located in current window decor");
            }
        }

Well, I do have in my app's activity's onCreate() the following line:

getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

But according to https://developer.android.com/reference/android/view/Window, the PROGRESS_VISIBILITY_ON constant was deprecated in API 24, FEATURE_PROGRESS and related methods are no longer supported starting in API 21.

How do I bring back my progress bar?



from E/PhoneWindows: "Horizontal progress bar not located in current window decor"

No comments:

Post a Comment