I have a mainactivity and a service. The mainactivity prepare data to the service. After the service consumed the data, it broadcasts a request to mainactivity, mainactivity prepare some new data and pass to service...
The mainactivity allows user to manipulate the data. The mainactivity will be killed after sometimes when if it is not in foreground.
[Problem 1]: I am a bit confused here, i think the mainactivity is still here, but its UI thread and view is cleared? So I cannot use the UI thread to read value from view and then send data to service?
[Problem 2]: How can I detect the mainactivity being killed and the service can then switch to prepare data itself?
[Problem 3]: How can I force the system to 'kill?' the mainactivity so I can debug the program?
thanks
Update: I read that graph may time but still i cannot fully understand the behavior. In fact, my question is more like this: From task manager, my app has 1 activity and 1 services and consumed 20MB ram. After half an hour, my app has 1 activity and 1 services and consumed 1.5MB ram. Obviously, something happened to the activity, what is that? Please be noted: my activity use UI thraad loop for preparing data to service. On stop / on resume has no impact on UI thead of activity, then how can i know when will the UI thread activity be killed?
Update: i tested with logcat, (add log message when onpause/onstop/ondestroy called..), however, none is called while the app memory drop down from 20mb to 1.5mb.
05-21 23:33:27.709: I/mytag(32012): called onResume
05-21 23:33:30.606: I/mytag(32012): called onPause
05-21 23:33:31.596: I/mytag(32012): called onStop
[up to this point, the app manager shows my app using 20mb memory]
05-21 23:36:05.176: D/skia(32012): purging 144K from font cache [8 entries]
05-21 23:36:05.246: D/dalvikvm(32012): GC_EXPLICIT freed 1240K, 52% free 4329K/8839K, external 1716K/2137K, paused 54ms
05-22 00:00:10.226: D/dalvikvm(32012): GC_EXPLICIT freed 933K, 53% free 4226K/8839K, external 1684K/2137K, paused 85ms
05-22 00:36:10.166: D/dalvikvm(814): GC_EXPLICIT freed 56K, 49% free 2775K/5379K, external 1625K/2137K, paused 61ms
[up to this point, the app manager shows my app using 1.5mb memory]
I waited half an hour, and i did not get any more logcat text, test ended.
I want to detect that system clear up my app memory, but it does not trigger any 'onpause, /onstop etc', how can i detect it, and then tell the service to do something? thanks