correct to put code in Process Globals ?

marcick

Well-Known Member
Licensed User
Longtime User
Sorry I posted before in the wrong section


Is it correct to put some code in Process globals (and not only declarations) ?
I mean a small code that read some variables from a file.
Marco
 

marcick

Well-Known Member
Licensed User
Longtime User
the result of that code is a variable that needs to be accessible also from a service module.
The service module is started at boot and I want it see that variable, without creating the main activity and without waiting the main activity is started from the user.

So, the choices in my mind were:

1) duplicate that code both in the service module and in activity_create
2) put that code in Process_Globals

But I'm not sure what I'm thinking and saying is correct.
Marco
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
I think duplicating the code will be a better/flexible option.
(You do not need to duplicate the code, just put it in a code module, and call it from both places).
The problem is that at boot, usually the sdcard is not ready, so your app will crash if your try to access the filesystem in process globals.

If you do duplicate the code in both places, make sure you do not re-initialize the variables (if that is relevant) by using IsPaused(Main) or IsPaused(Service).
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Careful with reading files upon a device boot, as already said by thedesolatesoul.
I have similar code in a service which starts at boot, what I do is to check for the files (until the sdcard is ready) by creating a timer. I process everything else, only when finally my sdcard is readable.
 
Upvote 0
Top