【发布时间】:2018-01-17 14:56:16
【问题描述】:
我正在使用与服务器连接的 android 应用程序, 而且我不允许更改网络服务, Web 服务与会话一起使用, 当我发送帖子或获取并且服务器与来自我的应用程序的会话一起工作时,如何让我的 android 应用程序像浏览器一样保存会话?
【问题讨论】:
标签: http android-studio session android-volley
我正在使用与服务器连接的 android 应用程序, 而且我不允许更改网络服务, Web 服务与会话一起使用, 当我发送帖子或获取并且服务器与来自我的应用程序的会话一起工作时,如何让我的 android 应用程序像浏览器一样保存会话?
【问题讨论】:
标签: http android-studio session android-volley
答案是在 apache 库中使用 Http-client 请求以这种方式发送:
HttpGet post = new HttpGet(url);
post.setHeader("User-Agent", "Android");
HttpResponse httpResponse = httpclient.execute(post);
一种像 php 一样保存会话的方法: 是使用android sharedPreferences 这是一个例子: https://www.androidhive.info/2012/08/android-session-management-using-shared-preferences/
【讨论】: