Is it possible to record audio on Android while lock screen is on?

随声附和 提交于 2019-12-22 00:38:42

问题


I'm writing a sound recorder app and I'm wondering if it's possible to activate the MediaRecorder while the phone has its lock screen up. If so, is it just a matter of a special permission or something else? Thanks in advance.


回答1:


you should try using PowerManager class with permission android.permission.WAKE_LOCK.

you can find more Here.




回答2:


Yes it is possible. Lock screen does not affect the working of services in an application. So if you are using a service, then your recording will proceed. However, if your phone is in standby, then it may not work. In that case, just grab a wakelock to keep the CPU alive and function your needs. However, grabbing a wakelock affects battery, so you must use it intelligently.



来源:https://stackoverflow.com/questions/13577810/is-it-possible-to-record-audio-on-android-while-lock-screen-is-on

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