Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

AndroidManifest: why no android.hardware.microphone = true?

Discussion in 'Android' started by Jelmersb, Dec 3, 2018.

  1. Jelmersb

    Jelmersb

    Joined:
    Jul 12, 2016
    Posts:
    66
    Hi

    According to Unity docs: "Unity automatically adds the necessary permissions to the Manifest based on the Player Settings and Unity APIs that your app calls from the script. "

    I use The Microphone class, which adds: RECORD_AUDIO
    However, this doesn't set android.hardware.microphone to true, so in the end, I still can't record audio. :confused:
     
  2. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    First of all, you have confirmed yourself that Unity docs are correct. We state that necessary permissions are added to the manifest and you've confirmed that RECORD_AUDIO permission is added. Now android.hardware.microphone is used for filtering the devices in the Play Store, so your app could be hidden in the Play Store on devices that don't have microphone. I don't think that would change if you can record audio or not on the device that has a microphone though. If what you are saying is really true and without specifying android.hardware.microphone in the manifest you are not able to record audio, please report a bug.
     
  3. Jelmersb

    Jelmersb

    Joined:
    Jul 12, 2016
    Posts:
    66
    Ok, I was in the assumption that my problems with recording audio were related to "android.hardware.microphone = true" being missing from AndroidManifest, but this is not the case.

    I don't have the app in the app store, but from what I experience from the closed and open beta on the Play Store: the app doesn't ask my beta users for permission to record through the microphone and crashes instead.

    So even though RECORD_AUDIO is present, this seems to not be enough?
    + In the google play app permissions (not shown upon installation of the beta), it says that the app MAY ask for microphone access. (but it doesn't and crashes). It does however ask for camera permission when the camera is accessed (AR Foundation), so I think there's still something wrong with the microphone implementation?
     
    Last edited: Dec 4, 2018
  4. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    To be able to use a feature that requires a permission, that permission has to be added to the manifest and the user must grant that permission to the application. Currently released Unity versions support only one way to ask for permissions and that is to ask for all permissions declared in the manifest at the start of the app. This behavior can be disabled by adding
    to the manifest. Based on your description I think that AR plugin adds this attribute to the manifest, which means Unity does not ask for any permissions and you are responsible for asking them yourself. We are going to add API for asking runtime permissions in Unity 2018.3, however for now you will have to use a plugin for that. Take a look at this https://github.com/Over17/UnityAndroidPermissions it should allow you to solve this issue.
     
    Yury-Habets likes this.
  5. Jelmersb

    Jelmersb

    Joined:
    Jul 12, 2016
    Posts:
    66
    Ah I see, thanks for the explanation! :)