The next major version of Android, Android P, which might be weeks away, it’s supposed to change such things. One of the focuses of Android P appears to be protecting user privacy. It will prevent background apps to record via microphone because at this time an app, idling away in the background, could be secretly recording you.
Instead of writing data from the microphone to a file, it’ll report empty data (a string of zeros in the byte array). Malicious apps will be also prevented to use the camera. If an inactive program will triy to use the camera, Android should shut it off and give an error message.This should prove to be a boon for security conscious users who will no longer have to worry. Android engineers explicitly mention in the source code commit that they’re adding this feature to “protect user privacy”. Since the Android P has yet to be officially announced, these submitted codes and functionality have not been guaranteed yet.