Hi Everyone,
I am working on Android with Java API. I want to show a button when the marker is detected and hide it when the marker is not detected just like the teapot. I can successfully show the button when any target (chips and stones) are detected. Thanks to the tutorial provided by Vuforia (“triggering-ui-events-when-target-detected”).
However, now that I can show the hidden button once the target is detected, it doesn’t hide when the target is no longer available. I am assuming that I might need to get the TrackerManager instance just like doLoadTrackersData() and doUnloadTrackersData() methods and find if the mCurrentDataset is active or not. However so far, I have failed miserably understanding this issue. Kindly help…. My onResume() code is below:
@Override protected void onResume() { Log.d(LOGTAG, "onResume"); super.onResume(); displayMessageHandler = new Handler() { @Override public void handleMessage(Message msg) { TrackerManager tManager = TrackerManager.getInstance(); ImageTracker imageTracker = (ImageTracker) tManager .getTracker(ImageTracker.getClassType()); String text = (String) msg.obj; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); if (text.equalsIgnoreCase("stones")) { Log.e("Is it Stones", text); b3.setBackgroundResource(R.drawable.up); b3.startAnimation(shake); b3.setVisibility(View.VISIBLE); } else if (text.equalsIgnoreCase("chips")) { Log.e("Is it chips", text); b3.setBackgroundResource(R.drawable.up); b3.startAnimation(shake); b3.setVisibility(View.VISIBLE); } else { Log.e("ELSE", text); b3.setVisibility(View.GONE); } } }; // This is needed for some Droid devices to force portrait if (mIsDroidDevice) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } try { vuforiaAppSession.resumeAR(); } catch (SampleApplicationException e) { Log.e(LOGTAG, e.getString()); } // Resume the GL view: if (mGlView != null) { mGlView.setVisibility(View.VISIBLE); mGlView.onResume(); } }
Hiding a UI element when target is not detected.
I can successfully show the button when any target (chips and stones) are dete
Hiding a UI element when target is not detected.
I managed to solve the problem by myself and wanted to answer it here. Really glad to see your reply Alessandro. Exactly like you suggested I realised that its
Hiding a UI element when target is not detected.
Glad to help ;-)