问题
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