Hello
part of my code:
/** Native function to receive touch events. */ public native void nativeTouchEvent(int actionType, int pointerId, float x, float y); /** Send touch events to native. */ @Override public boolean onTouchEvent(MotionEvent event) { int action = event.getAction(); int actionType = -1; int pointerIndex = -1; this.display_toast("onTouchEvent: MotionEvent.ACTION_Touch" ); switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: // on click this.display_toast("onTouchEvent: MotionEvent.ACTION_DOWN" ); actionType = 0; for (int i = 0; i < event.getPointerCount(); i++) { int pointerId = event.getPointerId(i); float x = event.getX(i); float y = event.getY(i); this.display_toast("onTouchEvent: pointerIndex: (" + Float.toString(x)+","+ Float.toString(y) + ")" ); String active_trackable_name = "???"; //String tracker_name = HOW TO GET CURENT TRACKER NAME ? if( active_trackable_name == "track1" ){ //TODO } else if( active_trackable_name == "track2" ){ //TODO 2 } else{ this.display_toast("There is no tracakble active or trackable is unknown"); } } break; } return true; }
Now the problem is: how to get CURENT TRACKER NAME
beacouse I want to do different actions on each trackables.
//String tracker_name = HOW TO GET CURENT TRACKER NAME ?
Any help :) ?
Thx
Niedved
Here's the general idea and then a code snippet:
When you touch the screen the OS passes the event to your java activity if you subscribe to it w/ onTouch method. From there it is your app's job to pass it to the native layer. Get the trackable name using QCAR APIs and then return it back to java layer and print to log.
Add this method to your cpp files:
(pseudo code)
You must add that signature to your java class too (like all JNI stuff).
Then in your java on the onTouch: (pseudo code)