Hello,

I need to pass a WebView param to a .java class in order to use
AddJavascriptInterface.

My java class is:

package MonoAndroidApplication1.Java;

import android.webkit.WebView;

public class PruebaHandler
{
  private WebView mAppView;

  public PruebaHandler()
  {
  }
        
  public void B(WebView appView)
  {
    mAppView = appView;
  }

  public String getGraphTitle()
  {
    return "Your Title";
  }
}

My code in C# is:

WebView webView1;
SetContentView(Resource.Layout.Main);
webView1 = FindViewById<WebView>(Resource.Id.webView1);

IntPtr PruebaHandler_Class =
JNIEnv.FindClass("MonoAndroidApplication1/Java/PruebaHandler");
IntPtr PruebaHandler_ctor = JNIEnv.GetMethodID(PruebaHandler_Class,
"<init>", "()V");
IntPtr PruebaHandler_B = JNIEnv.GetMethodID(PruebaHandler_Class, "B",
"(Landroid/webkit/WebView;)V");
IntPtr instance = JNIEnv.NewObject(PruebaHandler_Class, PruebaHandler_ctor);
JNIEnv.CallVoidMethod(PruebaHandler_Class, PruebaHandler_B, new
JValue(webView1));

When last instruction is executed I receive a Java.Lang.ClassCastException

What I'm doing wrong?

Thanks, regards,
Javigu

--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/AddJavaScriptInterface-tp5597876p5597876.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to