0 votes
by (140 points)

Unity: 2020.3.34f1, 2021.3.1f1
Unity packages:
XR Interaction Toolkit Version 1.0.0-pre.4 - May 19, 2021;
XR Plugin Management Version 4.2.0 - October 21, 2021,
Device: Pico Neo 3 Pro
PUI: 4.6.3

Example Java:

public class SomeClass
{
    public void CallIntent(Activity activity)
    {
        Intent intent = new Intent();
        intent.setClass(activity, SomeActivity.class);
        activity.startActivity(intent);
    }   
}

public class SomeActivity  extends Activity
{
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        InitIntent();
    }
    public void InitInten()
    {
        Intent intent = new Intent("android.intent.action.Any_Intent_Name");
        Log.i("Unity", "startActivityForResult");
        this.startActivityForResult(intent, 0);
        //ex: this.startActivityForResult(new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES).setData(Uri.parse(String.format("package:%s", getPackageName()))), 1234);
        //ex: this.startActivityForResult(new Intent("android.intent.action.INSTALL_PACKAGE"), 1);
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    {
        Log.i("Unity", "onActivityResult(" + requestCode + "," + resultCode + ")"); //Never called
        this.finish();
    }
}

Example Unity C#:

public class Example : MonoBehaviour
{
    private const string unityPlayerActivityName = "com.unity3d.player.UnityPlayer";
    private const string currentActivityFieldName = "currentActivity";
    private const string someClassName = "com.*****.*****.SomeClass";

    private AndroidJavaClass unityPlayerClass;
    private AndroidJavaObject unityActivity;
    private AndroidJavaObject someClassObject;

    public void Awake()
    {
        unityPlayerClass = new AndroidJavaClass(unityPlayerActivityName);
        unityActivity = unityPlayerClass.GetStatic<AndroidJavaObject>(currentActivityFieldName);
        someClassObject = new AndroidJavaObject(someClassName);
    }
    public void Start()
    {
        someClassObject.Call("CallIntent", unityActivity);
    }
    public void OnDestroy()
    {
        someClassObject?.Dispose();
        unityActivity?.Dispose();
        unityPlayerClass.Dispose();
    }
}

Explanation:
If I build empty build in Unity on Pico Neo 3 device with SDK:
1) PicoXRPlatformSDK-1.2.5B81;
2) UnityXR-2.0.4
B62;

Log.i("Unity", "startActivityForResult"); - was called
Log.i("Unity", "onActivityResult(" + requestCode + "," + resultCode + ")"); //Never called

But... If I build without checking "XR Plug-in Management -> Android -> Plug-in providers -> PicoXR" (disabled), and run on Pico Neo 3 device, it's working...

Also, it's working alright in Pico G2 4K with PicoXRPlatformSDK-1.2.5_B81;

1 Answer

0 votes
by (39.1k points)

Dear developer,
Sorry for the inconvenience, the application in VR mode does not support calling startActivityForResult method, because the system does not support it at present.

...