HTTP Volley headers in Android 8.0

2019-07-11 18:53发布

问题:

Since Android 8.0 has been released, I have problem with authorization header.

Is there any other way to add header into Volley request?

This doesn't work properly on the last Android version.

@override
public Map<String, String> getHeaders() throws AuthFailureError {
    Map<String, String> params = new HashMap<String, String>();
    params.put("x-api-key", App.apiAuth);
    return params;
}

Update:

It's work fine on all devices but Android 8.0. In Android studio simulator for 8.0 it works too.

So, problem is just with Android Oreo. It's using compile 'com.android.volley:volley:1.1.0-rc1' Device is Pixel 1.

App works fine when I disable authorization from API, but with authorization on the API side I have to add authorization header in the app, and app isn't able to download anything from the API. That's the problem, and it occurs only on Android 8.0.

Thanks in advance