Search code examples
androidvolumeandroid-audiomanagerlocked

Android Media Volume locked after I kill


I have a huge bug in my app. After I finish the app the volume is muted and it's locked.

Even when I quit and restart the app the volume is still locked at mute. The only way to restore the volume is to restart the phone. Please help! The app is a 2 webviews and one of the webviews is a video stream.

The log says this every time I push the volume button:

02-12 11:45:12.939: V/AudioHardwareMSM76XXA(115): AudioHardware::getParameters()
Fm-radio=

02-12 11:37:29.639: D/LKW(198): mShowing= false mNeedToReshowWhenReenabled= false
mUpdateMonitor.isDeviceProvisioned()= true

My audio manager methods:

@Override
protected void onPause() {
    super.onPause();
    am = (AudioManager) getSystemService(AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, true);
    lock.release();
}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    am = (AudioManager) getSystemService(AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, false);
    lock.acquire();

}
**

Solution

  • It turns out that something was causing a task to not be killed. It was bugging the phones volume and the app was running in the background and consuming RAM and battery. I solved it by killing the all the tasks myself.

    Add KILL_BACKGROUND_PROCESSES to the manifest. Then kill the tasks.

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        final ActivityManager amm = (ActivityManager)Class.this.getSystemService(Activity.ACTIVITY_SERVICE);
        amm.restartPackage("com.liyicky.dbzhd");
        amm.killBackgroundProcesses("com.liyicky.dbzhd");
    
    }