Right. So you have to enable voice commands at SYSTEM LEVEL. I probably turned that on ages ago, forgot about it, and after an OS upgrade haywire I flashed the device I got the default setting back, which is off.
May I respectfully point out it's a bit weird the device actually asks for permission for a permission it cannot use because it's turned off? Maybe it's a good idea to actually give a hint for that in the prompt when it asks for permission?
I have reported your feedback to our voice of customer team. In the meantime, you may be able check the current system settings via an Android object. You can reference the JavaUtils script inside the MRTK 3 package.
Here is a simplified example of how you could read the system settings:
private void ReadSystemVoiceInputSettings()
{
try
{
// Access the UnityPlayer class to get the current Android activity
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
// Get the ContentResolver from the current activity
AndroidJavaObject contentResolver = currentActivity.Call<AndroidJavaObject>("getContentResolver");
// Access the android.provider.Settings$System class
AndroidJavaClass systemSettings = new AndroidJavaClass("android.provider.Settings$System");
// Read the value of the system setting "enable_voice_cmds"
int mlVoiceEnabled = systemSettings.CallStatic<int>("getInt", contentResolver, "enable_voice_cmds");
// Check the value and log the result
if (mlVoiceEnabled == 1)
{
Debug.Log("ML Voice Input is Enabled");
}
else
{
Debug.Log("ML Voice Input is Disabled");
}
}
catch (AndroidJavaException e)
{
// Handle potential exceptions (e.g., setting not found or permission issues)
Debug.LogError("Error reading system settings: " + e.Message);
}
}