On Aug 3, 2012, at 6:53 AM, jose medrano <[email protected]> wrote:
> #### MONODROID CODE #####
>
> protected override void OnCreate(Bundle bundle)
> {
> [...]
> LinearLayout layout =
> FindViewById<LinearLayout>(Resource.Id.MyLayout);
> var webView = new WebView(this);
> webView.SetWebChromeClient(new WebChromeClient());
> webView.Settings.JavaScriptEnabled = true;
In general, setting JavaScriptEnabled should be done _after_ calling
AddJavascriptInterface(), otherwise you get occasional bizarre timing issues...
At least, that's been my experience.
> webView.AddJavascriptInterface(new JSAccesibleObject(),
> "cSharpObject");
> webView.LoadUrl("file:///android_asset/test.html");
> layout.AddView(webView);
> }
>
> public class JSAccesibleObject : Java.Lang.Object
> {
Add a reference to Mono.Android.Export.dll to your Application project, then
add the [Export] attribute to JSAccessibleObject.method1():
[Export]
> public void method1()
> {
>
> }
> }
See also:
http://docs.xamarin.com/android/advanced_topics/java_integration
http://androidapi.xamarin.com/?link=T:Java.Interop.ExportAttribute
Thanks,
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid