File Picker on Magic Leap 2

I’m trying to use a file picker on Magic Leap 2 with Unity and MRTK3 that allows users to browse and select a file using the system’s file browser. The picker should return the full file path (including the filename and extension) so I can access the selected file within my Unity application.

Unity version: Unity 6 (6000.0.37f1)
ML2 OS version: 1.12.0
Host OS: Windows 11
MRTK version: MRTK3

Here’s the method I’m currently trying to use for Magic Leap 2:

private async Task<string> FilePicker_Android()
{
    using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
    using (AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
    using (AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent", "android.intent.action.OPEN_DOCUMENT"))
    {
        intent.Call<AndroidJavaObject>("setType", "*/*");
        intent.Call<AndroidJavaObject>("addCategory", "android.intent.category.OPENABLE");
        currentActivity.Call("startActivityForResult", intent, 42);
    }

    // I want to return the selected file path here
    string filePath = ""; // How can I get the file path from the Intent's result?
    return filePath;
}

Trough that code i can successfully open the file browser on the device. But once i select a file, nothing happens—the result isn’t returned to Unity. I have no idea how to get the filepath from the intent. I have the required storage rights because I can query and load files with an direct path → e.g. “/storage/emulated/0/Datasets/data.csv”

Has anyone successfully implemented a working file picker on Magic Leap 2? What’s the best approach to retrieve the selected file path in Unity? Any help would be greatly appreciated!

I recommend taking a look at the following plugins. One allows you to pick a file using the system file picker. The other is a virtual file browser that can be edited to work on the Magic leap as well.

Many thanks for the answer and helpful links!!

I have already found the UnitySimpleFileBrowser and started to use it. Since this GUI is unfortunately more suitable for 2D applications, I am currently trying to change the code so that it can be accessed and interacted using the Magic Leap Controller.

The file browser already available on the device would be a great alternative here as it is already adapted to the system - unfortunately I have not yet had any success in getting the path after successfully clicking on a file.