I am calling a service from an AlarmManager onReceive, below is the implementation. I want to know if this implementation of a wake lock is fine and will it suffice my needs?
This is the onStart function in my Service Class:
@Override
public void onStart(Intent intent, int startId) {
WakeLock wakeLock = null;
try{
PowerManager mgr = (PowerManager)getApplicationContext()
.getSystemService(Context.POWER_SERVICE);
wakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
wakeLock.acquire();
//For time consuming an long tasks you can launch a new thread here
Toast.makeText(this, " Service Started", Toast.LENGTH_LONG).show();
}catch(Exception e){
}finally{
wakeLock.release();
}
}