Android Question Messing up globals

btg1967

Member
Licensed User
Hi there,

After broadening my POC app, I now have almost 10 activities, and supporting code modules to control them - this covers off some of the prototyping of screen flow, however now to start sharing objects and classes.

I was hoping to declare a global central class to store some information about the local device/user (), however can't get globals to be seen in other activities.

Basic architecture is code module "Main"
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim APP_NAME = "My App Name" As String

End Sub

Sub Globals

'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

End Sub
Sub Activity_Create(FirstTime AsBoolean)
'Do not forget to load the layout file created with the visual designer. For example:
StartActivity("modActLogin")​
End Sub

I can't seem to get the variable APP_NAME to be viewable in another activity. and do not close the "Main" activity.

I realise this might be due to scoping, however want to be able to share variables across modules without having to directly cast it to the next suite of modules.

I also realise that I'm almost certain it's because I'm just missing something *really* simple :-\
 

btg1967

Member
Licensed User
Thanks Erel, and a terrifically quick reply.

Ahh - the missing link (on my part) - now I (think I) get it.

All activities are essentially objects that can be referenced from 'anywhere' provided they haven't been Activity.Finish(ed)?

..probably described perfectly in page xx of the (very comprehensive) manual - so now to see if I can do the same with a globally declared variable of type MyClass ;-)
 

btg1967

Member
Licensed User
YAY - it worked :) ... not that that was too surprising - :) loving this tool to get this POC working...
 
Top