2 years ago

#63037

test-img

Julio Emen

AudioManager issue in Android 12

I have an issue with a Samsung Galaxy Note20, Android 12, phone. When a notification is received for the app, the notification listener executes the code below to adjust the volume of the sound that will be played (different sounds depending on notification data received). The code had issues in Android 10 in very specific models but the issues dissappeared when those phones upgraded to Android 11. Now I have the same issue in one Android 12 phone,but not sure if this will become more recurrent. The issue is that when the phone receives the notification and is about to play the sound the phone hangs and stays hanged making a strange noise and basically it becomes useless until the battery is drained and it can be reboot. Even more strange is that no crash report is recorded in crashlytics neither the performance tab in google play console. This was the same behaviour as in Android 10 for those very specific models. I found that it was an Android 10 issue thanks to this post: https://github.com/google/ExoPlayer/issues/8191. But now I am not sure if this is again an Android issue or not, and there is no available upgrade for that Galaxy Note 20 yet. Please advise. Thanks

 AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
        if (audioManager != null) {
            volumen_maximo= audioManager.getStreamMaxVolume(3);
        }
        if (audioManager != null) {
            volumen_actual=audioManager.getStreamVolume(3);
        }

        for (i=1; volumen_actual< (0.5*volumen_maximo); i++ ){

            if (audioManager != null) {
                audioManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
            }
            if (audioManager != null) {
                volumen_actual=audioManager.getStreamVolume(3);
            }
        }

android

android-audiomanager

0 Answers

Your Answer

Accepted video resources