How to add/edit onActivityResult for the activity created by currentActivity

Hi all,

I have a problem that not being able to set the onActivityResult(int requestCode, int resultCode, Intent data) for the "currectActivity created in C#(Unity).

In Unity I have the code like this :

private AndroidJavaObject ajo;
 void Start()
    {
        AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        ajo = jc.GetStatic<AndroidJavaObject>("currentActivity"); 
        ajc.CallStatic ("playVideo");

    }

From C# I call this method in Java:

private void playVideo() {
        ....
        startActivityForResult(intent, REQUEST_FOR_RESLUT);
    }

However, because I do not know how to set the onActivityResult() method for the activity in C#, the startActivityForResult is just like a startActivity. I cannot get any callback from onActivityResult() .

I would appreciate if you can provide any help. Thanks.

onActivityResult is a callback method that is called when an activity you started returns with some value.

What you should do:

  1. Create your own custom activity class (see details on how to do that in this link: Unity - Manual: Create and use plug-ins in Android). Specifically, look for the section named “Extending the UnityPlayerActivity Java Code”.
  2. In the activity you create, you should handle the onActivityResult callback method. Add whatever handling code you need (e.g: call back into Unity using UnitySendMessage, or whatever handling you need.