I'm writing an Android app and my app functions as expected except when it is left running in the background for long periods of time. When I resume the app after several hours, it crashes. I have waited the time period and watched the response in LogCat, which pointed to a null pointer exception in my code, however after surrounding that area of code in a try catch (and executing correctional code in the catch) it still crashes after several hours of inactivity. My question is, is there a way I can manually force the garbage collector (or whatever the Android O/S is doing after several hours of my app running in the background) so I can efficiently debug my issue without having to wait hours for it to happen naturally? Thanks in advance StackOverflow community!
System.gc()
will ask to shedule the garbage collector, but will not force it.
Calling the garbage collector will not solve the NullPointerException.
I would suggest to try to debug, use a Profiler instead