Android : AudioHardware pcm playback is going to standby
In my HTC Desire (Froyo) , I initiated a call from the a android app and when t开发者_如何学运维he call ends, my android app gone to standby mode by showing
" AudioHardware pcm playback is going to standby " in log cat. when i press the back button, only then i can control my app... how can i prevent calling the standby mode..
Add this permission to your AndroidManifest.xml:
<uses-permission android:name="android.permission.WAKE_LOCK" />
Then in onCreate()
:
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyTag");
mWakeLock.acquire();
And in onDestroy()
:
if (mWakeLock != null) {
mWakeLock.release();
mWakeLock = null;
}
精彩评论