开发者

android application save state

I am having trouble while developing Android application.

i declare custom search critiera object into application context, from every activity i want to access search critiera object from application context and then want to change Search critiera object.

oncrate() method i get searchcritiera and onresume i save th开发者_C百科is object into application context's search criteria.

ON an activity i have detect gps button when user click on the button it detect and store location object into search critiera.

  • There are two problems, how can retain the search critiera object along the application cycle while every activity wants to change search critiera values ?

  • when i move around and any other application comes front of my activity search critiera gets null from application context ....

help me out.


In any activity whenever the search criteria is changed to another value you can save it in SharedPreferences. If you want to save the old value you can put it in a vector, then put it in SharedPreferences else just put the new value to ShraedPreferences.

In case of onResume() fetch the value with its tag name from SharedPreferences.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜