0

Android 4.1.2 の Cookie に問題があります。私の aap は android 2.+ と android 4.0 で Cookie を正しく処理しますが、android 4.1.2 では http 投稿要求を送信した後、サーバーから 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 に答える