Log in or register to post comments

Extending QCARPlayerActivity, finish activity issue.

November 9, 2011 - 5:30am #1

Hi all,

I know that the subject of how to build a Unity package with eclipse has been already discussed on this forum. My post is not about how to do it.

Indeed, I already have an application working. It has a main activity showing a start button able to launch another activity which extends "com.qualcomm.QCARUnityPlayer.QCARPlayerActivity". My app works fine, I'm able to launch the Unity part which tracks and augments correctly my marker.

However I cannot go back to my Main activity. As for the Unity side, I used the method Application.quit() when the user press the back button, but this method force the entire app to close.

Is there a way to finish my extended QCARPlayerActivity without finishing the entire application?

Many thanks for all advices.

Hidden

Extending QCARPlayerActivity, finish activity issue.

July 3, 2014 - 8:20am #20

Hi

I found this Topic and think my question still fits in...

 

I have an Activity named -  UnityVuforiaActivity extends QCARPlayerNativeActivity - 

Its mainly the same, described here:  https://developer.vuforia.com/resources/dev-guide/extending-unity-android-activity-and-adding-custom-views-eclipse

The UnityVuforiaActivity gets started from an other Activity - LoginActivity - 

Now by pushing a button (and/or the backButton) i want to get back from the running UnityVuforiaActivity to my previous LoginActivity.

So i use this funktionality: http://docs.unity3d.com/ScriptReference/Application.Quit.html

The LoginActivity starts up, but after a short time the UnityVuforiaActivity onDestroy Method gets called and quits the Application.

 

FIX:

fixed it with this line in the Manifest: android:launchMode="singleTask"

 

Vuforia sdk v3.0; Unity 4.5.1

Extending QCARPlayerActivity, finish activity issue.

October 11, 2012 - 6:53pm #19

Thanks for posting that - if you can post a snippet of your code, please do.

Extending QCARPlayerActivity, finish activity issue.

October 9, 2012 - 7:53am #18

For anyone having a similar issue...

Later when testing, realized that calling super.onDestroy(); closes my app completely in some phones.

So finally found a better solution.
In the activity which extends the Unity activity (or QCARPlayerActivity/QCARPlayerProxyActivity ), when calling the next activity called it like startActivityForResult(Intent, int) instead of startActivity and added another method in that class onActivityResult(int, int, Intent). And called finish() inside this method.

Now it seems to work fine and properly close the Unity instance.

Extending QCARPlayerActivity, finish activity issue.

October 5, 2012 - 12:46pm #17

That's a good question. These issues seem to arise from calling Application.Quit from Unity. We've seen reports of similar problems. An alternative may be to use Unity's AndroidJavaObject to call into the Android context to manage the Activity - http://docs.unity3d.com/Documentation/ScriptReference/AndroidJavaObject.html

Extending QCARPlayerActivity, finish activity issue.

October 5, 2012 - 4:50am #16

I fixed the unity instance closing issue like this

Extended the QCARPlayerActivity (earlier I had QCARPlayerProxyActivity )
Called super.onDestroy(); in the public void onPause() method of the activity which extends the QCARPlayerActivity ... called onDestroy within some if condition...

Also set android:noHistory="true" for QCARPlayerProxyActivity,  QCARPlayerNativeActivity in application manifest file and QCARPlayerActivity, QCARPlayerProxyActivity,  QCARPlayerNativeActivity in unity library manifest file.  (Dont' know whether this is necessry or not)

It works but not sure whether that's a proper way to do it.

 

 

Extending QCARPlayerActivity, finish activity issue.

October 5, 2012 - 3:12am #15

Angie, Kim,

 

Do we need to set android:noHistory="true" for qualcomm activities in both our application project and unity library project or in which one?

And also do we need to set android:noHistory="true"  for the activity which is extending QCARPlayerProxyActivity ?

 

Thanks

Extending QCARPlayerActivity, finish activity issue.

July 20, 2012 - 9:55am #14

Hi everybody.

I have followed this post and I still have trouble finishing my Vuforia activity. I've got 2 activities: MainActivity.java with the main menu of my app, when user press the camera button calls ARStage.java that creates the Unity activity with Vuforia. On Unity I have a menu with "Close AR" option, but when it's pressed the QCAR activity finish and I can see the previous activity (MainActivity) for about 2 seconds and then it's finished too.

After followed this post now I have this behavior. When "Close AR" option inside Unity is pressed, the activity is finished and I can see the previous activity (MainActivity) for 2 seconds and finish, but inmediately creates a new one MainActivity and works fine. My question is: How can I avoid Qcar activity finish all my app? how I keep the first activity without create a new one?

This code its from MainActivity:

    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if ((keyCode == KeyEvent.KEYCODE_CAMERA)) {

        Intent intent = new Intent(this, org.air.ar.ARStage.class);

        startActivity(intent);

        }

        return super.onKeyDown(keyCode, event);

    }

 
This is from ARStage that extends com.qualcomm.QCARUnityPlayer.QCARPlayerActivity. I need to create a new intent of MainActivity, cos the first one is finished by QCAR:
 
public static ARStage currentActivity;
    
    private Handler uiHandler;
    private Button myButton;
    
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        currentActivity = this;
        
        uiHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                myButton.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        switchActivity();
                    }
                });
            }
        };
    }
    
    public void switchActivity()
    {
    Intent intent = new Intent(this, org.air.browser.MainActivity.class);
    startActivity(intent);
    finish();
    }
 
And C# code inside Unity:
 
// Finish Activity
        if (GUILayout.Button("Close AR", buttonGroupStyle))
        {
            AndroidJavaClass jc = new AndroidJavaClass("org.air.ar.ARStage");
            AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
            jo.Call("switchActivity");
        }
 
Any hint or help will be appreciated. Thank you.
 
Best Regards, Alex.

Extending QCARPlayerActivity, finish activity issue.

June 27, 2012 - 2:30pm #13

You need to copy the link, and paste it on the navigation bar, or write the direction directly

Extending QCARPlayerActivity, finish activity issue.

June 24, 2012 - 11:39am #12

Hello , i try to enter to the links in this post but i enter in the same page... (sorry mi english :P) 

Re: Extending QCARPlayerActivity, finish activity issue.

April 13, 2012 - 3:12pm #11

Great news, thanks for sharing!

- Kim

Re: Extending QCARPlayerActivity, finish activity issue.

April 13, 2012 - 10:19am #10
ksiva wrote:

I'm not sure we'll be able to help with this one, it's far outside the standard use case and it sounds like it might be a known Unity issue.

Have you tried a similar application flow for an app that doesn't use QCAR?

- Kim

hello Kim, thank you so much for your help =)!!!

i have good news, the problem is fixed when android:nohistory is defined in all qualcomm activities (not just QCARPlayerProxyActivity)

Re: Extending QCARPlayerActivity, finish activity issue.

April 12, 2012 - 7:52pm #9

I'm not sure we'll be able to help with this one, it's far outside the standard use case and it sounds like it might be a known Unity issue.

Have you tried a similar application flow for an app that doesn't use QCAR?

- Kim

Re: Extending QCARPlayerActivity, finish activity issue.

April 12, 2012 - 10:03am #8

Hi kim,

android:noHistory (manifest) and set flags in intents don´t work.

Re: Extending QCARPlayerActivity, finish activity issue.

April 11, 2012 - 9:34pm #7

So I haven't tried this before... Note that the ProxyActivity starts another Activity (the actual Unity Activity), so to return to your Menu Activity you need to go back two levels. You can try setting the android:noHistory flag on the ProxyActivity, so when you finish the Unity Activity you jump straight back to your Menu. Does that work?

- Kim

Re: Extending QCARPlayerActivity, finish activity issue.

April 11, 2012 - 7:58am #6
ksiva wrote:

Are you using Unity 3.4? We've seen occasional ANR issues with Unity 3.4 that have since been fixed in 3.5. I recommend upgrading, let us know if that helps!

- Kim

Hi Kim!, yes, i´m using unity 3.5.

i don´t know if i expressed my problem correctly, the flow of navigation is:

start app->start menu activity -> start QCARPlayerProxyActivity -> return to menu --- here everything is ok, but if i do:

start app->start menu activity -> start QCARPlayerProxyActivity -> return to menu -> start QCARPlayerProxyActivity again --- here, QCARPlayerProxyActivity show a blank screen and show anr dialog.

i think, when i call QCARPlayerProxyActivity and launch unity, and back, unity is still running, but is not show properly.

how i can close unity activity, and keep application running?

thank you a lot for your help and sorry for my english u_u

PD. the problem is similar to the last post, from here:
http://forum.unity3d.com/threads/75360-Is-there-any-way-to-close-Activity

Re: Extending QCARPlayerActivity, finish activity issue.

April 10, 2012 - 3:49pm #5

Are you using Unity 3.4? We've seen occasional ANR issues with Unity 3.4 that have since been fixed in 3.5. I recommend upgrading, let us know if that helps!

- Kim

Re: Extending QCARPlayerActivity, finish activity issue.

April 10, 2012 - 2:13pm #4

hi Kim, i use the implementation from this link:
https://ar.qualcomm.at/arforums/show...60&postcount=4

and i have a problem, when the user turn back to android application (menu activity); its ok !, but, if we do again (open augmented reality activity from menu), the app is frozen and Application Not Responding dialog appear.

help!

Re: Extending QCARPlayerActivity, finish activity issue.

November 10, 2011 - 7:46am #3

Hi Kim,

Many thanks for your answer. It worked perfectly for me (using a singleton logic for the UnityPlayer).

Hidden

Re: Extending QCARPlayerActivity, finish activity issue.

November 9, 2011 - 4:55pm #2

Unity doesn't provide a mechanism for changing activities, but you can call Java methods directly from a Unity script. See this post for some sample code that might get you started:

http://ar.qualcomm.at/node/2000434

- Kim

Log in or register to post comments