K karyadi Member Licensed User Longtime User Oct 23, 2016 #1 Hi All, i have a question, How to Keep public variable when device get into deep sleep? because every time my device get into deep sleep, all my variable become null. thanks
Hi All, i have a question, How to Keep public variable when device get into deep sleep? because every time my device get into deep sleep, all my variable become null. thanks
Erel B4X founder Staff member Licensed User Longtime User Oct 26, 2016 #21 marcick said: These two variables, are kept forever (until the app is closed or killed by OS of course) or can happen the app RESUME with NULL in them ? Click to expand... No and yes. test2 is an activity variable. Its life cycle is tied to the activity life cycle. However it will never be "null" as you are setting it correctly in Activity_Create. Rules of thumb: - All non-ui global variables should be process global variables and set when FirstTime is true. - All public process globals should be declared in the starter service and set in Service_Create sub. Upvote 0
marcick said: These two variables, are kept forever (until the app is closed or killed by OS of course) or can happen the app RESUME with NULL in them ? Click to expand... No and yes. test2 is an activity variable. Its life cycle is tied to the activity life cycle. However it will never be "null" as you are setting it correctly in Activity_Create. Rules of thumb: - All non-ui global variables should be process global variables and set when FirstTime is true. - All public process globals should be declared in the starter service and set in Service_Create sub.
An Schi Well-Known Member Licensed User Oct 26, 2016 #22 Erel said: - All non-ui global variables should be process global variables and set when FirstTime is true. Click to expand... Is it dangerous to set them everytime the app starts and not only when FirsTime is true? @marcick : Thanks for keep on digging here Sometimes i'm just doing things and when there are questions i see that i don't understand what i am doing.... Maybe this is a good topic for a new tutorial written by an expert Upvote 0
Erel said: - All non-ui global variables should be process global variables and set when FirstTime is true. Click to expand... Is it dangerous to set them everytime the app starts and not only when FirsTime is true? @marcick : Thanks for keep on digging here Sometimes i'm just doing things and when there are questions i see that i don't understand what i am doing.... Maybe this is a good topic for a new tutorial written by an expert
Erel B4X founder Staff member Licensed User Longtime User Oct 26, 2016 #23 An Schi said: Is it dangerous to set them everytime the app starts and not only when FirsTime is true? Click to expand... If it is a simple string then no. However if it is a more complex object such as SQL object then it can cause problems. Upvote 0
An Schi said: Is it dangerous to set them everytime the app starts and not only when FirsTime is true? Click to expand... If it is a simple string then no. However if it is a more complex object such as SQL object then it can cause problems.
tigrot Well-Known Member Licensed User Longtime User Oct 27, 2016 #24 I had to rewrite my first app: i distributed variables everywhere with no real plan, so some of them was lost in activity pause and some where retained because declared in services. As I always say: "results are unpredictable" when you code in such a way. Upvote 0
I had to rewrite my first app: i distributed variables everywhere with no real plan, so some of them was lost in activity pause and some where retained because declared in services. As I always say: "results are unpredictable" when you code in such a way.