Code example for HttpContext

Methods: setAttribute

0
   
  public AppengineClient(Context context) {
    accountManager = (AccountManager)context.getSystemService(Context.ACCOUNT_SERVICE);
    account = accountManager.getAccountsByType("com.google")[0];
 
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
  } 
   
  @Override 
  protected void finalize() { 
    httpClient.close();
  } 
   
  public HttpEntity sendRequest(HttpUriRequest request) throws IOException {
    if (getCookie() == null) { 
      if (!fetchCookie()) { 
        // One retry for the case where the ClientLogin token has expired. 
        accountManager.invalidateAuthToken("com.google", authToken);
        authToken = null;
        if (!fetchCookie()) { 
          throw new IOException("Failed to get appengine cookie");