4

I make my device as admin after installation.

Media player is not playing any audio when application is in LockTask (KIOSK Mode)

I have written a handle to enable/disable KIOSK MODE

I am trying to play a simple audio file from res/raw. Volume of the device is set to high.

 mediaPlayer = MediaPlayer.create(context, R.raw.panic_ring)
        mediaPlayer?.start()
        mediaPlayer?.isLooping = true

But still I cannot hear anything from device

If I disable KIOSK mode by calling enableKioskMode(false) then I can hear sound just fine.

James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

1
  1. Make sure that you have not set User Restriction in DevicePolicyManager i.e UserManager.DISALLOW_ADJUST_VOLUME
  2. Add code to put your phone on RINGER mode with full volume
    private fun setDeviceOnRingerMode(applicationContext: Context) {
        val am: AudioManager? =
            applicationContext.getSystemService(Context.AUDIO_SERVICE) as AudioManager?
        am?.ringerMode = AudioManager.RINGER_MODE_NORMAL
        Settings.System.putInt(
            applicationContext.contentResolver,
            android.provider.Settings.System.NOTIFICATION_SOUND,
            1
        )
    }