startActivityForResult crashes program

I’m trying to build an android sina weibo plugin for unity, and their authentication requires the calling activity to override onActivityResult. Since I’m passing in unity’s activity as the context for the authentication, I will need to override the function on Unity’s activity. However, I am reluctant to implement a custom Unity activity as this might cause other problems with the rest of my plugins.

Instead, I have opted to create a middle-man activity which calls my authentication activity with startActivityForResult. The problem is that the problem stops working once the line of code is called. I have tried adding debug lines and try catch the block in logcat. No exceptions are getting thrown and I’m sure the function is being called, but the other activity is not getting started and the program just stops there.

Here’s the Unity c# codes

public class weibo_manager : MonoBehaviour
{

    AndroidJavaClass jc;
    AndroidJavaObject activity;
    AndroidJavaClass myJC;
    AndroidJavaObject myJO;
    public Text txt;
    public Text debug;

    // Use this for initialization
    void Start ()
    {
        try{
            AndroidJNI.AttachCurrentThread();
            jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity = jc.GetStatic<AndroidJavaObject>("currentActivity");

            activity.Call("runOnUiThread", new AndroidJavaRunnable(runOnUiThread));

        }
        catch(Exception e)
        {
            debug.text = e.Message;
        }
    }

    void runOnUiThread()
    {
        using (myJO = new AndroidJavaObject("com.sina.weibo.sdk.demo.WBResultAdapter"))
        {
            if (myJO != null)
            {
                debug.text = "myJO not null";
                myJO.Call("init");
            }
            else
            {
                debug.text += "myJO is null";
            }
        }
    }
}

and here’s the middle-man activity I’m calling

Could anyone point me in the right direction? Is this due to some issue with passing Unity’s context around or is there a better way to go about doing this?

Did you find any solution for this?

@anon_27663045 -chorus
Did you fin any solution for this?