2
私は認可を得てサイトのAndroidクライアントを開発しています。私はpostメソッドを持っています。例コード:AndroidのHttp Cookieストア
public void run() {
handler.sendMessage(Message.obtain(handler, HttpConnection.DID_START));
httpClient = new DefaultHttpClient();
HttpConnectionParams.setSoTimeout(httpClient.getParams(), 25000);
HttpResponse response = null;
try{
switch (method){
case POST:
HttpPost httpPost = new HttpPost(url);
httpPost.setHeaders(headers);
if (data != null) httpPost.setEntity(new StringEntity(data));
response = httpClient.execute(httpPost);
break;
}
processEntity(response);
}catch(Exception e){
handler.sendMessage(Message.obtain(handler, HttpConnection.DID_ERROR, e));
}
ConnectionManager.getInstanse().didComplete(this);
}
クッキーを保存するには?
このラインエラー 'クッキークッキー= BasicClientCookie( "名前"、 "値"); '。 'Cookie cookie = new BasicClientCookie(" name "、" value ");'? – monomi
はい、私の間違いは、 'new'キーワードを忘れました。 –
文字列mCookies []はヘッダー[]でなければなりませんmCookiesそれ以外の場合は型キャストの問題になります。 – Noman