I am trying to aquire a wake lock however when I call PowerManager.newWakeLock() I receive a IlleglArgumentException.
Here is the code I use to get the
private void setWakeLock(Context context)
{
PowerManager pm = (PowerManager) context
.getSystemService(Context.POWER_SERVICE);
SoundAlarmActivity.WakeLock = pm.newWakeLock(
PowerManager.ACQUIRE_CAUSES_WAKEUP
| PowerManager.ON_AFTER_RELEASE, "Alarm");
SoundAlarmActivity.WakeLock.acquire();
}
And here is the logcat:
09-28 12:53:09.704: ERROR/AndroidRuntime(702): java.lang.IllegalArgumentException
09-28 12:53:09.704: ERROR/AndroidRuntime(702): at android.os.PowerManager$WakeLock.<init>(PowerManager.java:223)
09-28 12:53:09.704: ERROR/AndroidRuntime(702): at android.os.PowerManager.newWakeLock(PowerManager.java:365)
Try this:
PowerManager.ACQUIRE_CAUSES_WAKEUP does not work with partial wake locks so you have to make sure you are using a FULL_WAKE_LOCK while defining the type of Wake Lock you want.