Process died / Scheduling emergency service restart

I have a service that is also a LocationListener. On a new location event, it is doing some networking stuff that can take time; why is it implemented as AsyncTask.

Often I see a real device in the log:

03-29 17:02:20.847 D/dalvikvm(  235): GC_FOR_ALLOC freed 961K, 29% free 10234K/14215K, paused 26ms
03-29 17:02:20.855 I/DemoService(  555): DiyScheduer.onStart
03-29 17:02:20.855 I/ggheart (  555): onStart
03-29 17:02:21.097 V/PhoneStatusBar(  235): setLightsOn(true)
03-29 17:02:21.121 W/IInputConnectionWrapper(11244): showStatusIcon on inactive InputConnection
03-29 17:02:21.277 I/ActivityManager(  161): Process (pid 11298) has died.
03-29 17:02:22.058 I/ActivityManager(  161): Process com.idavydov.myapp (pid 11051) has died.
03-29 17:02:22.066 I/WindowManager(  161): WIN DEATH: Window{41b05850 com.idavydov.myapp/com.idavydov.myapp.MyActivity paused=false}
03-29 17:02:22.074 W/ActivityManager(  161): Scheduling restart of crashed service com.idavydov.myapp/.MyService in 5000ms


This usually happens after downloading a large application.

Is the reason for this low memory? In that case, why is there no such message in the log?

PS In another question I saw an explanation that the reason is that the task is taking too long. But I added the following code to my AsyncTask and was unable to reproduce the crash in the emulator.

    protected Boolean doInBackground(...) {
        long time = System.currentTimeMillis();
        while (System.currentTimeMillis() - time < 11 * 1000);




source to share

1 answer

I think you are confusing two things. Android doesn't allow blocking the UI thread and if it does it will kill your application. Unless you put the lock and loop handling in a background AsyncTask process.

Also, android will kill your application without warning when it has low memory or it indicates that your application is not affecting the user. If you want your app to last longer, you need a sticky service and good app lifecycle management.



All Articles