Code example for PowerManager.WakeLock

Methods: acquire

0
                // It can take hundreds of ms flush the audio pipeline after 
                // apps pause audio playback, but audio route changes are 
                // immediate, so delay the route change by 1000ms. 
                // This could be improved once the audio sub-system provides an 
                // interface to clear the audio pipeline. 
                mWakeLock.acquire();
                mHandler.sendEmptyMessageDelayed(0, 1000);
            } else { 
                updateAudioRoute(); 
            } 
        } 
    } 
 
    private synchronized final void sendIntent(boolean isUnplug) {
        //  Pack up the values and broadcast them to everyone 
        Intent intent = new Intent(Intent.ACTION_HEADSET_PLUG);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
 
        intent.putExtra("state", mHeadsetState);
        intent.putExtra("name", mHeadsetName);