I override QCAR (Thanks, Kim~).
I Call Toast.makeText(). Application close.
my QCAR Override java source(.jar file) is
public class OverrideExample extends com.qualcomm.QCARUnityPlayer.PlayerActivity
{
//public static Activity currentActivity;
public static OverrideExample currentActivity;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
currentActivity = this;
}
public void toastMsg()
{
Context context = getApplicationContext();
String text = "Call by Unity";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
and, My Unity C# code is
AndroidJavaClass jc = new AndroidJavaClass("com.QCAR.CAPTEST.OverrideExample");
AndroidJavaObject jo = jc.GetStatic
jo.Call("toastMsg");
and, My AndroidManifest.xml
android:configChanges="keyboardHidden|orientation">
...
what problum?
Help~me~~
Ah, it looks like the Unity script is running in a different thread than the Android UI thread. You can only spawn a toast from the UI thread. You'll want to set up a Handler object on the main UI thread to take care of this. There's some sample code in this post (not Unity-specific, but the general idea holds):
http://ar.qualcomm.at/node/2000032
- Kim