Log in or register to post comments

Change image

November 20, 2011 - 4:35am #1

I make Augmented Reality with QCAR SDK, my application concept is to show 3d object if correct marker detected by camera..

and if we tap the object, the information and photos about the object appear

my problem is, i have more than 3 marker, so basically i hava a different information and photos depend on object..so far, i can change the the information(text) if different object tapped, but i cannot change the image..can anyone solve my problem

this is my jni code to show information refer on object tapped:

void
showDetails(char* message)
{
    // For this application, buttons are handled by the Android SDK
    // Use the environment and class stored in initNativeCallback
    // to call a Java method that shows the delete button
	jstring js = javaEnv->NewStringUTF(message);
    jmethodID method = javaEnv->GetMethodID(javaClass, "showDetails", "(Ljava/lang/String;)V");
    javaEnv->CallVoidMethod(javaObj, method, js);
}
ImageTargetsRenderer.mainActivityHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				// Context context = getApplicationContext();
				String text = (String) msg.obj;
				int img2 = R.drawable.rsbunda;
				final Dialog dialog = new Dialog(ImageTargets.this);
				dialog.setContentView(R.layout.custom_dialog);
				dialog.setTitle("Informasi Lokasi");
				dialog.setCancelable(true);
if (strcmp(trackable->getName(), "st_pndkcina_M") == 0){
                	showDetails("Stasiun Pondok Cina - Jl. Kemiri Muka, Depok");
                        }
                else if (strcmp(trackable->getName(), "st_ui_M") == 0){
                               	showDetails("Stasiun Universitas Indonesia - Jalan Lingkar Kampus Raya, Depok");
                               		}
                else if (strcmp(trackable->getName(), "bank_bni_M") == 0){
                	showDetails("Bank BNI - Jl. Margonda Raya 48, Depok");
                		}
........

this is my showdetails method code in java :

public void showDetails(String text) {
		DebugLog.LOGD("Show Delete called");
		Message message = new Message();
		message.obj = text;
		mainActivityHandler.sendMessage(message);
	}

and this is my handler activity :

ImageTargetsRenderer.mainActivityHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				// Context context = getApplicationContext();
				String text = (String) msg.obj;
				int img2 = R.drawable.rsbunda;
				final Dialog dialog = new Dialog(ImageTargets.this);
				dialog.setContentView(R.layout.custom_dialog);
				dialog.setTitle("Informasi Lokasi");
				dialog.setCancelable(true);
				// there are a lot of settings, for dialog, check them all out!

				// set up text
				TextView text1 = (TextView) dialog
						.findViewById(R.id.TextView01);
				text1.setText(text);

				// set up image view
				ImageView img = (ImageView) dialog
						.findViewById(R.id.ImageView01);
				img.setImageResource(img2);

				// set up button
				Button button = (Button) dialog.findViewById(R.id.Button01);
				button.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						dialog.dismiss();
					}
				});
				// now that the dialog is set up, it's time to show it
				dialog.show();

			}
		};

Regards, Gyan

Change image

November 13, 2012 - 2:32am #4

@ muhammadgyan;

you can follow the very good suggestion from harism;

also, if you want to keep using strings, you could create a HashMap on the Java side that uses the strings as keys, and asssociates them to values like the image resource id or anything you want.

 

 

Change image

November 13, 2012 - 1:56am #3

Hi, to solve this here's one way you could try. Instead of passing a String to showDetails() -method, you could use a marker id instead. It would be an integer which makes it possible to do a switch-case for example on Java side to choose correct details String and Image. With the exception of using Integer instead your code flow looks like it worked out of the box with this change.

Change image

November 8, 2012 - 10:24am #2

can u give me some tutorial about this? i want to show text like ur app..thnks

Log in or register to post comments