На всякий случай, если у кого-то еще возникла такая же проблема, у меня была похожая проблема, и я смог решить ее с помощью следующего кода:
1 - Определите CookieManager и CookieStore в своем классе
CookieManager cookieManager;
CookieStore cookieStore;
2 - добавить обработчик файлов cookie по умолчанию, например, в конструкторе класса или в методе OnCreate
cookieManager = new CookieManager();
CookieHandler.setDefault(cookieManager);
3 - использовать хранилище cookie при выполнении HTTP-запроса
public byte[] openURI(String uri) {
try {
URI uriObj = new URI(uri);
DefaultHttpClient client = new DefaultHttpClient();
// Use the cookieStor with the request
if (cookieStore == null) {
cookieStore = client.getCookieStore();
} else {
client.setCookieStore(cookieStore);
}
HttpGet getRequest = new HttpGet(uriObj);
HttpResponse response = client.execute(getRequest);
// Read the response data
InputStream instream = response.getEntity().getContent();
int contentLength = (int) response.getEntity().getContentLength();
byte[] data = new byte[contentLength];
instream.read(data);
response.getEntity().consumeContent();
return data ;
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}