Log in or register to post comments

Starting the native activity from an other activity

February 18, 2014 - 2:18pm #1

Hi all,

 

  I've been developing an AR application with Unity and exported succesfully to Eclipse. I've been able to execute it from Eclipse, starting from the native activity, but when I try to start it from an other activity (a welcome one), I only see the Unity logo and then nothing, only the black screen and some errors in the log cat, but the application doesn't crash. These are the errors:

02-18 23:16:34.025: E/Unity(19807): Could not initialize the tracker.
02-18 23:16:34.025: E/Unity(19807):  
02-18 23:16:34.025: E/Unity(19807): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 53)
02-18 23:16:34.025: E/Unity(19807): Could not initialize the tracker.
02-18 23:16:34.025: E/Unity(19807):  
02-18 23:16:34.025: E/Unity(19807): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 53)
 
then more log lines without errors...
 
02-18 23:16:34.035: E/AR(19807): 2014-02-18 23:16:34: Failed to set hint 'HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS' because the ImageTracker has not been initialized.
 
more no log errors, and finally...
 
02-18 23:16:34.360: E/AR(19807): 2014-02-18 23:16:34: CameraDevice::getCameraCalibration(): Failed to get camera calibration because the camera is not initialized.
 
 
Does anyone know how to solve this? I've been Googling for hours and I found almost nothing :S
 
Thank you in advance, Daniel

 

Starting the native activity from an other activity

February 19, 2014 - 12:29pm #7

Great!

Starting the native activity from an other activity

February 19, 2014 - 12:09pm #6

I solved it!!

 

I was calling on the new Intent at "UnityPlayerNativeActivity.class", the one with all the native activity stuff, but then, looking at the manifest, I saw that there was a different name there, defining the class: "com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity". I changed the intent creation to that one, and now works perfectly :D:D:D:D

 

 

Thank you very much for your time and help, Daniel 

Starting the native activity from an other activity

February 19, 2014 - 11:30am #5

Nope, it doesn't work either. I get the same Unity logo screen and then only a black screen. The logCat still shows the same errors about  not initializing the tracker: 

 

02-19 20:24:32.070: E/Unity(7894): Could not initialize the tracker.
02-19 20:24:32.070: E/Unity(7894):  
02-19 20:24:32.070: E/Unity(7894): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 53)
02-19 20:24:32.070: E/Unity(7894): Could not initialize the tracker.
02-19 20:24:32.070: E/Unity(7894):  
02-19 20:24:32.070: E/Unity(7894): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 53)
 
02-19 20:24:32.100: E/AR(7894): 2014-02-19 20:24:32: Failed to set hint 'HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS' because the ImageTracker has not been initialized.
 
02-19 20:24:32.805: E/AR(7894): 2014-02-19 20:24:32: CameraDevice::getCameraCalibration(): Failed to get camera calibration because the camera is not initialized.
 
02-19 20:24:32.835: E/Unity(7894): Data set heart3 does not exist.
02-19 20:24:32.835: E/Unity(7894):  
02-19 20:24:32.835: E/Unity(7894): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 53)
 
 
But I don't get this errors when I start the app directly on the UnityPlayerNativeActivity.
 
I have tried to start it from the one which extends it and I get the same errors.
 
I have also tried on other phone and doesn't work either. I have tried it in samsung galaxy S2 and S4

 

Starting the native activity from an other activity

February 19, 2014 - 4:32am #4

If you look at this article:

https://developer.vuforia.com/forum/faq/unity-how-can-i-extend-unitys-android-activity

you will see that you have to change the Android Manifest.xml to specify your own Activity class name (i.e. the one which extends the UnityPlayerNativeActivity), for instance "com.example.MyUnityVuforiaActivity"   instead of the UnityPlayerNativeActivity; 

then, when you start the Activity via an Intent, you should specify your actual Activity class name in the Intent constructor. This should work.

 

 

Starting the native activity from an other activity

February 19, 2014 - 2:08am #3

First thing, thanks for answering so fast :D

 

So, I've checked those links, but this is a problem after all that. I'll try to explain it in a more easy way:

 

App1 -> (Main activity/Launcher) UnityPlayerNativeActivity: Shows an Unity logo and the camera starts perfectly, so I can point at my AR images and it shows my 3D model

App2 -> (Main activity/Launcher) Other class with a button* -> press the button -> goto UnityPlayerNativeActivity: shows the unity logo but the camara doesn't start and the screen remains black.

*To open the other class, I use:

             Intent intent = new Intent(this,UnityPlayerNativeActivity.class);

             startActivity(intent);
 
Apparently this should work, but it doesn't. Could it be a problem of my phone? I haven't tested in other phones yet, but I'll soon try. If this works in an other phone, I'll leave a reply here, else, I'll be still waiting for some help (if possible)
 

Starting the native activity from an other activity

February 18, 2014 - 11:42pm #2

Not sure what you are doing wrong, but have you checked these articles?

https://developer.vuforia.com/forum/faq/unity-how-can-i-extend-unitys-android-activity

https://developer.vuforia.com/forum/faq/unity-android-plugins

Those explain how to export a Unity (Vuforia) project to Eclipse (first article) and how to integrate Android plugin into Unity (second article); I guess you are more interested in the first one, but note that the second appraoch is also possible.

Then, launching the Unity-Vuforia activity from another activity should be just a matter of adding your activity to the Android Manifest and then calling startActivity() in the code.

In my experience this should work flawlessly, but checkj the article abive just to see if perhaps you can find some specific steps that you did differently..

 

Log in or register to post comments