I’m going through some memory issues with my Android development.
I was wondering if my actual model would work, and also would like some input on how to do this in a better way:
- I need
public static finalglobals - I need
publicglobal variables that never gets garbage collected - I need to have an Engine running and never destroy without me calling
stop()
MainApplication : Application
public static final Boolean DEBUG = false;
onCreate()
Engine.getEngine().prepare()
MainActivity : Activity
onResume()
Engine.getEngine().start()
onPause()
Engine.getEngine().stop()
Engine
prepare()
MainApplication.DEBUG = true;
start()
LocationManager.requestLocationUpdates()
stop()
LocationManager.removeUpdates()
Engine is a Singleton class, receiving location updates and such.
It is imperative that my Engine class does not get released not the DEBUG variable.
For your “Type 1” constants use a dedicated public class containing
public static final T NAME = Val;– declarations.For the Engine, I’d recommend using a Service.
For your “Type 2” vars, the Service could offer getters or you could make use of SQLite.
I see there’s some “Location”-Stuff going on there … the developer website has some good “best practices” on using the Location Services. Maybe there you’ll get some more inspiration.