Trying to save the value of the cookie to store the device in the store, but not every time I boot the application again return null value, I do not know why we do not store the value of the cookie.
final HttpUriRequest request = new HttpGet(uri);
request.setHeader("User-Agent", Sonora.USER_AGENT);
try {
DefaultHttpClient client = new DefaultHttpClient();
if(cookieValue != null) {
Log.d(TAG,"COOKIE RECEBIDO E ARMAZENADO");
request.setHeader("Cookie", cookieName + "=" + cookieValue);
}
HttpResponse resp = client.execute(request);
// Check if server response is valid
StatusLine status = resp.getStatusLine();
if (status.getStatusCode() != Sonora.HTTP_STATUS_OK) {
Log.e(TAG, "HTTP error, invalid server status code: " + resp.getStatusLine());
return;
}
final List<Cookie> cookies = client.getCookieStore().getCookies();
int count = cookies.size();
for( int i = 0; i < count; i++ ) {
final Cookie c = cookies.get(i);
if ( c.getName().compareTo( cookieName ) == 0 ) {
cookieValue = c.getValue();
break;
}
}
} catch (IOException e) {
Log.e(TAG, "IOError error", e);
}