0

我对 android 4.1.2 上的 cookie 有疑问。我的 aap 可以在 android 2.+ 和 android 4.0 上正确使用 cookie,但在 android 4.1.2 上,我在发送 http post 请求后无法从服务器获取 cookie。我的代码:

public void auto() 
    {
        EnterActivity.httpclient = new DefaultHttpClient();


        EnterActivity.mHttpContext = new BasicHttpContext();
        EnterActivity.mCookieStore = new BasicCookieStore();

        EnterActivity.mHttpContext.setAttribute(ClientContext.COOKIE_STORE, mCookieStore);



        HttpPost httpost = new HttpPost("http://.../oh.php");

        System.out.println("LOLOLOLOLOOLOLO");
        MultipartEntity entity = new MultipartEntity();
        try 
        {

            entity.addPart("login",new StringBody( getLastLogin() )); 
            entity.addPart("password", new StringBody( getLastPassword() ));


        } 
        catch (UnsupportedEncodingException e1) 
        {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }




        HttpResponse response = null;
        try 
        {
            response = EnterActivity.httpclient.execute(httpost, EnterActivity.mHttpContext);

        } 
        catch (ClientProtocolException e) 
        {
            // TODO Auto-generated catch block


            e.printStackTrace();
        } 
        catch (IOException e) 
        {

            dialogHandler.post(new DialogView( CONNECTION_ERRO ));
            e.printStackTrace();

            return ;
        }


        HttpEntity resEntity = response.getEntity();

        if(mCookieStore.getCookies().size()>0)
        System.out.println(" mCookieStore.getCookies().get(0).getValue(); =="
                + mCookieStore.getCookies().get(0).getValue());
        else
            System.out.println(" mCookieStore.getCookies().get(0).getValue(); == :(((");

...
}
4

1 回答 1

0

我编辑了我的时区、日期和时间的设置。并且应用程序正常工作:)

于 2013-05-30T22:35:20.917 回答