Hi,
we are using unity for our AR app. In Android when we have in AR content something like send text button and user hits it we pass to native code request to open sendign text activity. Here is a native code we call from Unity
public void sendSMS(final String number, final String text){ Log.d("NativeWrapper", "sendSMS called, number:"+number); UnityPlayer.currentActivity.runOnUiThread(new Runnable() { public void run() { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse( "sms:" + number )); intent.putExtra( "sms_body", text ); UnityPlayer.currentActivity.startActivityForResult(intent, 1);; } }); }
The issue we have is that if you cancel sendign text in Messaging activity by pressign back button ONCE only all is fine and the Unity app is shown and continue where it ended.
However if you cancel text message by pressing back button and then again press back button while the unity activity is not yet restored, then the app exits.
This issue shows up on all devices we tested here. We do handle key down for ESC key in unity code ourselves, so when in unity activity pressing back does not close the app, but it seems like when there is no unity activity fully active yet, there is somewhere default back handling which does close the app as there is nothing else in activity history stack.
We tried to override public void onBackPressed() and public boolean onKeyDown() in ExtendedPlayerActivity which extends QCARPlayerProxyActivity. We start this activity as main application activity. But these methods are not triggered. Is QCARPlayerProxyActivity starting another activity which is active at the time back is pressed? is there a way to override that activity onBackPressed() to handle the event in such situations?
The issue I described is happening quite often because for instance on Tablets going back from send Email or send text activities take lieke 1 or 2 seconds and user tends to press back again thinking he did not hit it properly as switching back to unity activity is not immediate and has its delay.
Thanks for help.
S.
Hi
Thanks for your time bro. I got that worked now. I found another way to get unity scripts calls in java and that by using android plugins. For the steps to create an android plugin check this link:
https://developer.vuforia.com/forum/faq/unity-android-plugins
Cheers!