I'm using the following code inside OnStartCommand of my service:

        wakelock =
myPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK ,
getString(R.string.app_name) );
        try {
                wakelock.acquire();
                wakelockAcquired = true;
        } catch (Exception e) {
                android.util.Log.e( getString(R.string.app_name) , "Unable to
acquire wake lock" );
        }

And then when I stop the service I use the following code, which I've
verified _is_ getting called:

                if( wakelockAcquired && (wakelock != null) ) {
                        try {
                                wakelock.release();
                                wakelockAcquired = false;
                        } catch (Exception e) {
                        android.util.Log.e( getString(R.string.app_name) , 
"Unable to
release wake lock" );
                        }
                }

After all this, I exit my application and check the settings, both on
a physical phone and on the emulator and the service is still in
memory. In addition, the onDestroy method of the service is never
getting called, despite the fact that the wakelock is released and the
parent activity that was originally bound to it is destroyed (and the
parent Activity called ServiceConnection.unbindService in its
onDestroy method).

What more can I do to kill off this zombie service?


-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to