I have a class Globals:

class Globals{
public static WakeLock myWakeLock = null;
public static WifiLock myWifiLock = null;
        }

In my ConnectService, onCreate() method, I acquire the wakelock using:
             wakeLock =
powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Lock");
if(!wakeLock.isHeld()&&(wakeLock!=null)){
Log.d(TAG,"Wake lock is acquired successfullyyyy ");
wakeLock.acquire();
Globals.myWakeLock = wakeLock;
}

I release it only in the onDestroy() of ConnectService:

try{
     if(Globals.myWakeLock!=null){
     Globals.myWakeLock.release();
     Globals.myWakeLock = null;
     Log.d(TAG,"WakeLock released successfully in onDestroy () method
hereeee!!!!");
     }

     }catch(Exception e){
     e.printStackTrace();
     Log.d(TAG,"Exception while releasing WakeLock :: Can be ignoredd");
     }


On Thu, Feb 7, 2013 at 2:52 PM, skink <[email protected]> wrote:

> i asked "so how do you acquire the wake lock"?
>
> i mean your java code
>
> pskink
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Regards,
Archana

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to