我正在使用与服务器连接的 android 应用程序,我不允许更改 web 服务,web 服务与会话一起工作,当我发送帖子时如何让我的 android 应用程序像浏览器一样保存会话或者获取并且服务器与我的应用程序中的会话一起工作?
答案是在 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/
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句