How to get audio volume on Android using JNI from native code?

不羁的心 提交于 2019-12-01 15:01:32

You need an instance of AudioManager to call that method. To get the instance, you can use context.getSystemService(Context.AUDIO_SERVICE) (as per documentation you linked to).

The AudioManager.cpp you linked to doesn't actually read the stream volume value, just the value of the static STREAM_MUSIC field and therefore doesn't need an instance of AudioManager.

The main problem in getting an instance of AudioManager here is really that to do that you need a Context instance, which is usually your Activity, Service or Application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!