Log in or register to post comments

Application closes!!!

March 21, 2012 - 2:53am #1

Well I Read Ksiva's post....
It stated how to change texture on tapping the screen...
Wel i hav in ImageTarget.cpp file----multiple targets loaded....

i.e I hav loaded mytaget1 with targetIndex= 0 as well as targetIndex=1
second mytarget2 with targetIndex=2...

I hav added in Imagetarget.java the following code

public boolean onTouchEvent(MotionEvent event)
if (event.getAction() == MotionEvent.ACTION_UP )
DebugLog.LOGI("swapping textures");

Texture temp = mTextures.elementAt(0);
mTextures.set(0, mTextures.elementAt(1));
mTextures.set(1, temp);

initApplicationNative(mScreenWidth, mScreenHeight);

// Run initRendering on the GL Thread
mGlView.queueEvent(new Runnable()
public void run()
return true;

Well what happens is the target is displayed wel for both mytarget1 and mytarget2....It even swaps well and changes the texture for mytarget1 on tapping the screen...
However when the mytarget2 is tracked the texture is displayed well but on tapping multiple times in short duration on mytarget2 the application closes!!!


I taught it would work well as even if i tap on other target it would just swap the position of mTexture 0 and mtexture 1...
The logcat also shows the log for swapping texture ...init deinitapplication native... AND NO ERROR IS DISPLAYED!!!

Re: Application closes!!!

March 25, 2012 - 8:52pm #7

Thanks Ksiva for your valuabe inputs...Its working great now:):):)

Re: Application closes!!!

March 23, 2012 - 10:31am #6

Note the changes to the method signature:

Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv* env, jobject obj)

The "env" variable is defined there.

- Kim

Re: Application closes!!!

March 23, 2012 - 9:41am #5

Hey Ksiva
I am trying with the code mentioned in above thread...
However i am getting following error while building native code in cygwin..

$ ndk-build
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi-v7a/gdbserver
Gdbsetup : libs/armeabi-v7a/gdb.setup
Compile++ arm : ImageTargets jni/ImageTargets.cpp: In function '_jstring* Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv*, _jobject*)':
jni/ImageTargets.cpp:129: error: 'env' was not declared in this scope
/cygdrive/c/Development/Android/android-ndk-r7/build/core/build-binary.mk:241: recipe for target `obj/local/armeabi/objs-debug/ImageTargets/ImageTargets.o' failed
make: *** [obj/local/armeabi/objs-debug/ImageTargets/ImageTargets.o] Error 1

Line 128 129 in ImageTarget.cpp is
jstring nameJ;
nameJ = env->NewStringUTF("empty");

I have also changed the return type of function to jstring..

Pls help rectifying the error...

Thank you
Regards Integration

Re: Application closes!!!

March 21, 2012 - 6:37pm #4

This thread has some code for returning the currently tracked target name from the renderFrame method:


- Kim

Re: Application closes!!!

March 21, 2012 - 3:07am #3

One possible solution which i can think off is the onTouchEvent is only invoked when that particular target is viewed by camera.....

However i dont knw how to get id of the marker currently viewed by camera....

If i can get this by any means in Java i can easily play with the Texture being displayed...

Re: Application closes!!!

March 21, 2012 - 2:56am #2

I tried tapping multiple times on mytarget1 as fast as i can....and it worked perfectly....

I cant figure out whats the problem....som1 pls help..

Log in or register to post comments