I’m working on android unity3d project where I want to post some stuff to facebook.
Basically the app is running activity which is out of my control. Facebook single sign on requires me to provide activity to show up its stuff.
Now the problem is that trigger to post to facebook is comming out from Unity activity (from native code through JNI). its basically my plain Java object as connector which is created from unity in native code and I can call it methods. I have also accessible reference to currentActivity. Still having troubles to do anything with it.
I always get
AndroidRuntime(12845): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
I tried to give this current activity reference to Facebook authorize() as activity to bind to but gives the error.
I tried to switch to my own activity where I wanted to start Facebook on it.
got the same error.
tried this
Intent intent = new Intent(UnityPlayer.currentActivity.getApplicationContext(), MyActivity.class);
UnityPlayer.currentActivity.startActivity(intent);
also few other similar things but just can’t switch activity.
How should I do this?
thanks
That is because UI operation cannot run on worker thread. You should try
runOnUiThread.