¡@

Home 

2014/10/16 ¤W¤È 08:14:11

android Programming Glossary: getlock

PowerManager wakelock not waking device up from service

http://stackoverflow.com/questions/17471028/powermanager-wakelock-not-waking-device-up-from-service

.Lock private static volatile WakeLock lockStatic null notice static synchronized private static PowerManager.WakeLock getLock Context context if lockStatic null PowerManager mgr PowerManager context .getSystemService Context.POWER_SERVICE lockStatic.. true return lockStatic public static void startYourService Context ctxt Intent i STATIC getLock ctxt.getApplicationContext .acquire ctxt.startService i public YourService String name super name setIntentRedelivery true.. true @Override public int onStartCommand Intent intent int flags int startId PowerManager.WakeLock lock getLock this.getApplicationContext if lock.isHeld flags START_FLAG_REDELIVERY 0 lock.acquire super.onStartCommand intent flags..

Android accelerometer not working when screen is turned off

http://stackoverflow.com/questions/9982433/android-accelerometer-not-working-when-screen-is-turned-off

the thread of an IntentService like in this code snippet bellow synchronized private static PowerManager.WakeLock getLock Context context if lockStatic null PowerManager mgr PowerManager context.getSystemService Context.POWER_SERVICE lockStatic.. SensorManager.SENSOR_DELAY_NORMAL synchronized this boolean run true while run try wait 1000 getLock AccelerometerService.this .acquire sensorManager SensorManager getSystemService SENSOR_SERVICE sensorManager.unregisterListener..