Hello Friends,

I have a service which holds on to a wakelock and the code is similar
to this,

public class WakeLockService extends Service {

PowerManager.WakeLock wl;

        @Override
        public IBinder onBind(Intent arg0) {
                // TODO Auto-generated method stub
                return null;
        }

        public void onCreate() {
                PowerManager pm = (PowerManager) getSystemService
(Context.POWER_SERVICE);
                wl = pm.newWakeLock (PowerManager.PARTIAL_WAKE_LOCK,
"My Tag");

                wl.acquire();
        }

        public void onDestroy() {
                wl.release();
        }


For past two days, my phone has been restarting randomly...Today it
was worse, it kept restarting untill I uninstalled the app.

I tried to search about this behaviour online and found that too many
wakelocks may coz the phone to restart. Can there be any other reason?

Is the above code right? Should make wl as a final variable? Does the
service call onDestroy method when phone shuts down?

I am using a broadcastreceiver to start my service at boot up as well.

Any help would be appreciated.

Thank You So Much

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to