API Level
Developers can set the minimum API level required for their applications as well as query the OS version to see up to wich API level is support. This section includes details about query the OS API level and specifying the minimum API level inside the Unity Editor.
Query Platform API Level
Developers can use the MLResult.Code MLPlatformGetAPILevel(ref uint level)
function to query the which Platform API Level is supported on the device at runtime. The function will return MLResult.Code.Ok
if operation was successful , MLResult.Code.UnspecifiedFailure
if failed due to internal error and MLResult.Code.InvalidParam
if the int level was not valid.
using System;
using UnityEngine;
using UnityEngine.XR.MagicLeap;
// Namespace that contains the function
using UnityEngine.XR.MagicLeap.Native;
public class PlatformLevelTest : MonoBehaviour
{
public uint GetPlatformLevel()
{
try
{
uint level = 0;
MLResult.Code resultCode = MagicLeapNativeBindings.MLPlatformGetAPILevel(ref level);
if (resultCode != MLResult.Code.Ok)
{
MLPluginLog.ErrorFormat("MLDevice.GetPlatformLevel failed to get platform level. Reason: {0}", resultCode);
}
else
{
return level;
}
}
catch (DllNotFoundException)
{
MLPluginLog.ErrorFormat("MLDevice.GetPlatformLevel failed. Reason: {0} library not found", MagicLeapNativeBindings.MLPlatformDll);
}
return 0;
}
}
Minimum API Level
Magic Leap Minimum API Level
The minimum API level is an important setting that tells the platform which APIs your application expects to use. It ensures compatibility of newer APKs with older versions of the Magic Leap Android Operating System. By specifying the minimum version supported by your application, the operating system can check if your APK will work with its APIs.
All Magic Leap 2 projects should set their Magic Leap Minimum API level to at least API level 20 (Edit > Project Settings..., then select MagicLeap > Permissions from the sidebar).
The Manifest Settings panel will filter the permissions that are associated with the selected API Level. Any permission not supported by that version will not be displayed. If you plan to use newer features as they become available, update the version accordingly.
Android Minimum API Level
In addition to the Magic Leap minimum API level, there's also a minimum API level setting for Android. For the Magic Leap platform, set it explicitly to level 29 to avoid potential issues with certain platform subsystems. You can find this setting under Project Settings > Player Settings > Android Platform (Android Icon) > Other Settings