Hi list !

I'm having this problem:

In my application, I use a GLSurfaceView for 3D rendering. The real
rendering is done by calling native methods, coded in C++.

Once in a while (upon user clicks on 3D scene objects) the native
rendering engine should be able to call Java methods (through JNI)
that display a dialog box.

I can't get it to work, that's driving me crazy.

Here is the native method:

[CODE]
void MyCPlusPlusClass::showDialog(const std::string& pMsg)
{
    jclass lClass = mJNIEnv->GetObjectClass(mActivity);
    if (!lClass)
    {
        return false;
    }
    jmethodID lMethId = mJNIEnv->GetMethodID(lClass,
"showMessageDialog", "(Ljava/lang/String;)V");
    if (!lMethId)
    {
        return false;
    }
    jstring lJavaString = mJNIEnv->NewStringUTF(pMessage.c_str());
    mJNIEnv->CallVoidMethod(mActivity, lMethId, lJavaString);
}
[/CODE]

Then, the method showMessageDialog, coded in Java, in my activity:

[CODE]
public void showMessageDialog(String pMsg)
{
    Log.i("Vg", "Create dialog with message " + pMsg);
    Log.i("Vg", "Show dialog");
    runOnUiThread(
        new Runnable () {
            public void run () {
                AlertDialog.Builder lAlertBox = new
AlertDialog.Builder(this);
                TextView lTextView = new TextView(MyActivity.this);
                lTextView.setText(mMessage);
                lAlertBox.setView(lTextView);
                lAlertBox.setNeutralButton("Ok", MyActivity.this);
                lAlertBox.setOnCancelListener(MyActivity.this);
                lAlertBox.show();
            }
        }
    );
}
[/CODE]

I thought this would work, but it doesn't. What am I doing wrong ?

Thanks
Florent.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to