Request Permission For Microphone On Android M
I need to utilize the microphone with Android M. I've tried setting up a permission group in the manifest, and can't get it working properly. Here's what I've got in the manifest:
Solution 1:
To request microphone, you should be requesting Manifest.permission.RECORD_AUDIO
instead of the permission group Manifest.permission_group.MICROPHONE
.
So, remove the tags <permission/>
and <permission-group/>
in the Manifest because they are to indicate that your want to create new permissions rather than use them.
Then to request the permission just do this:
if (ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(),
newString[]{Manifest.permission.RECORD_AUDIO},
REQUEST_MICROPHONE);
}
Post a Comment for "Request Permission For Microphone On Android M"