想要改进这个问题吗? 更新问题,使其只关注一个问题
Closed 8 years ago.
我是自我学习和机器人和java的自我学习者。 在和机器人的java中,是否有可用的会话变量? 如果有的话,请告诉我其目的和过程。 如果可能的话,请用样本告诉我。
谢谢你的宝贵时间!
当谈论会议时,你指的是什么?
因为如果你谈论会话 以存储登录证书或用户信息。
如果您谈论临时数据储存,比如从互联网下载的数据或其他应用程序相关数据,则打算在整个应用程序中共享的数据,可以使用多种方式分享,例如Application class ,s >/stopic
sub>变量,
Android 没有我所知道的会话变量。 但是, 如果您的 Android 应用程序正在与网络服务器通信, 您的应用程序可以使用网络服务器上的 PHP 会话变量。 下面是 :
1) Android app sends user s login credentials to your web server (www.your-web-server.com/login.php)
2) login.php checks the credentials and then calls session_start()
to begin a session.
3) login.php then calls something like this: my_current_session = session_id();
in order to get the session ID of the current session.
4) login.php then sends the session ID (my_current_session
) back to the Android app. I recommended echoing the session ID as a JSON-encoded string (json_encode).
5) The Android app stores the session ID locally. You can stored it in SharedPreferences as some of the other answers have suggested. Or you can store it in a SQLite database locally on the device.
6) You can then include the session ID in the Request Headers of all future GET and POST requests from the Android app to the web server. The PHP running on the web server will recognize the session ID and make the associated session variables available.
为何您需要它。。在应用程序启动时,有应用程序变量可以初始化。您也可以将单吨级设定为先菜。
在会话中没有存储值的 spi 可用, 相反您可以使用 < a href=" http:// developmenter.android.com/ reference/android/content/ sharedPreferences.html" rel=“ nofollow” >SharedPreference , 或者可以使用静态变量存储您想要在会话中保存的值 。
使用共享首选项 。
您可以找到一个 < a href=>", http://www.tutominalspoint.com/android/android_Adroid_Adroid_Adroid_previews.htm" rel= "not follow noreferrer" >example 。
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...