Wrong language? Choose different language instead:

close

HttpCookie

HttpCookie
verfasst am 13.08.2012 10:31:25 — geändert am 16.08.2012 08:03:00
Hallo!

Ich habe eine Frage betreffend Android Cookies.

Ich erstelle einen Login-Cookie der wie folgt ab Android 2.3 funktioniert:

1private void createCookie() {
2
3 Map<String, List<String>> allHeaderFields = connection.getHeaderFields();
4 List<String> allCookieFields = allHeaderFields.get("Set-Cookie");
5
6 for (int i = 0; i < allCookieFields.size(); i++) {
7
8 List<HttpCookie> cookies = HttpCookie.parse(allCookieFields.get(i));
9
10 for (int j = 0; j < cookies.size(); j++) {
11
12 HttpCookie cookie_http = cookies.get(j);
13 String cookieKey = cookie_http.getName();
14 String cookieValue = cookie_http.getValue();
15
16 if (cookieKey.equals("saml")) {
17 loginCookie = cookieValue;
18 } // IF
19
20 } // For
21
22 } // For
23 }

Nun will ich aber die App auch auf einem Android 2.2 Smartphone installieren und da gibt es "HttpCookie" noch nicht.
Kann mir jemand eine Info geben, wie der Code für Android 2.2 dann aussehen könnte.

Habe jetzt schon in einigen Foren gesucht und div. Möglichkeiten versucht, bekomm es jedoch nicht hin.

Vielen Dank im Voraus für eure Hilfe!

Danke,
Verena
Antworten mit Zitat Antworten Link ±0     (0 Stimmen)
RE: HttpCookie
verfasst am 17.08.2012 08:04:14
Hat niemand eine Idee??? :(
Antworten mit Zitat Antworten Link ±0     (0 Stimmen)
RE: HttpCookie
verfasst am 17.08.2012 09:07:52
Warum machst Du das denn händisch und nicht über den CookieStore des HttpClient?
Der speichert Cookies doch automatisch und du kannst nach dem GET/POST Request darauf zugreifen.

-----
Verkaufswert Rechner -- Verkaufswert Rechner Online -- 1-Klick Kleinanzeigen -- MadMonitor -- AndroidPIT Dev Stats -- Directupload.net Image Sharer

Antworten mit Zitat Antworten Link ±0     (0 Stimmen)