ksiva wrote:
You'll want to use the JNI (Java Native Interface) to call a java method from native. See this post for some sample code that displays a Toast in java when a trackable is found:
http://ar.qualcomm.at/node/2000032
- Kim
Thanks Kim for reply. I already seen that post and tried to implement my coding also. As that post based on to show text and my intention to call from native to play video, I finding difficulties here. Anyway I posted my coding here:
ImageTargets.cpp :
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv* env, jobject obj)
{
. . . . .
for(int tIdx = 0; tIdx
{
int textureIndex = (!strcmp(trackable->getName(), "stone")) ? 0 : 1;
const Texture* const thisTexture = textures[textureIndex];
jstring js = env->NewStringUTF(trackable->getName());
jclass javaClass = env->GetObjectClass(obj);
jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V");
env->CallObjectMethod(obj, method, js);
}
ImageTargets.java :
public static Handler mainActivityHandler;
//calling my video playback code from here
public void displayMessage(String text)
{
Intent intent = new Intent(this,MediaPlayerDemo_Video.class);
intent.putExtra(MEDIA,LOCAL_VIDEO);
startActivity(intent);
}
protected void onResume()
{
ImageTargetsRenderer.mainActivityHandler = new Handler() {
public void handleMessage(Message msg) {
. . . . . . . .
//don’t know what to written here as the mentioned code for showing text
}
It’s successfully built and installed in phone. But after detect the marker, the program exit automatically. As the given[post] code for showing text, so can you help me to convert the coding to call from native to play video… Under display message function, my video code is there.
Thanks
Rassall
You'll want to use the JNI (Java Native Interface) to call a java method from native. See this post for some sample code that displays a Toast in java when a trackable is found:
http://ar.qualcomm.at/node/2000032
- Kim