Log in or register to post comments

[UnityAndroid] MainActivity extends Activity, is it possible?

August 19, 2012 - 10:42pm #1

Hi,

is it possible for my MainActivity to extend Android's Activity instead of QCAR's Activities?

I need to use the layout I have made in Java (Eclipse). I'm using Unity as a sub view just like: http://forum.unity3d.com/threads/98315-Using-Unity-Android-In-a-Sub-View?p=642398&viewfull=1#post642398

 

I have tried to manually extending QCARPlayerActivity / QCARPlayerNativeActivity as described here: https://ar.qualcomm.at/content/integrating-eclipse-extending-qcarplayeractivity#comment-2006876

It runs but the Unity Player takes out the whole screen, it is the same like extending QCARPlayerProxyActivity. I assume those classes override my layout just like in UnityPlayerActivity / UnityPlayerNativeActivity.

 

So, is it possible to extend Activity and then calls something like vuforia.init()?

I have tried to call QCAR.Init() but the app just crashes. While the QCARUnityPlayer.Init(int, bool), I don't know what to fill those parameters.

Even if know, I don't know are there any other functions I should call in order to initialize QCAR properlly.

Pardon my English, I hope I described the problem clear enough.

 

Thanks!

[UnityAndroid] MainActivity extends Activity, is it possible?

September 19, 2012 - 1:24pm #6

Can you send me an example of the view that you're trying to overlay? I'll see if I can work out a way to do this for apps that are extending the QCAR activities.

[UnityAndroid] MainActivity extends Activity, is it possible?

September 17, 2012 - 7:46am #5

Hi,

I have a similar Android+Vuforia+Unity problem, I want to see a custom layer over vuforia default layer. I've tried to use this DavidBeard GLSurfaceView solution but I can only see my custom layer before splash screen. Once vuforia layer is active my custom layer dissapears.

This is my code:

public class myActivity extends  QCARPlayerActivity {    

@Override

    public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

mGLView = new GLSurfaceView(this);

       mGLView.setRenderer(new ClearRenderer());

       

       LayoutInflater inflater = getLayoutInflater();

       View mOverlayView = inflater.inflate(R.layout.subview, null);

       

       addContentView(mGLView, new LayoutParams(

                    LayoutParams.FILL_PARENT,

                    LayoutParams.FILL_PARENT));

    

        addContentView(mOverlayView, new LayoutParams(

                    LayoutParams.FILL_PARENT,

                    LayoutParams.FILL_PARENT));

   }

 

   @Override

   protected void onPause() {

       super.onPause();

       mGLView.onPause();

   }

 

   @Override

   protected void onResume() {

       super.onResume();

       mGLView.onResume();

   }

 

   private GLSurfaceView mGLView;

 

 

}

 

 

class ClearRenderer implements GLSurfaceView.Renderer {

   public void onSurfaceCreated(GL10 gl, EGLConfig config) {

       // Do nothing special.

   }

 

   public void onSurfaceChanged(GL10 gl, int w, int h) {

       gl.glViewport(0, 0, w, h);

   }

 

   public void onDrawFrame(GL10 gl) {

       gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

   }

}

 

Sorry about my english, I hope someone can help me. Thank you.
 
 

[UnityAndroid] MainActivity extends Activity, is it possible?

August 26, 2012 - 11:35am #4

I don't know how to do that, if it's invovling creating layout programatically, I'll just change my application flow, it's easier that way for me...

 

If your layout is already defined, in /res/layout, you should be able to add it as such..

                            addContentView(mGlView, new LayoutParams(
                                            LayoutParams.FILL_PARENT,
                                            LayoutParams.FILL_PARENT));

                            addContentView(mOverlayView, new LayoutParams(
                                            LayoutParams.FILL_PARENT,
                                            LayoutParams.FILL_PARENT));

 

In that example the mOverlayView is layered on top of the mGLView, which is the view used by Vuforia in native android apps.

[UnityAndroid] MainActivity extends Activity, is it possible?

August 20, 2012 - 11:23pm #3

DavidBeard wrote:

Vuforia needs to occupy the full device screen in order to overlay augmentations accurately.

Hmm, ok, I don't want to ruin that. I'll just change my application flow...

 

DavidBeard wrote:

Can you overlay your app's views on the Unity view?

I don't know how to do that, if it's invovling creating layout programatically, I'll just change my application flow, it's easier that way for me...

[UnityAndroid] MainActivity extends Activity, is it possible?

August 20, 2012 - 10:26am #2

Yes it's being overridden. Vuforia needs to occupy the full device screen in order to overlay augmentations accurately. Can you overlay your app's views on the Unity view?

Log in or register to post comments