JavaScript / Native app inter communication in Android


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. WebViewwebView=(WebView)findViewById(R.id.web_view);
  2.  
  3. WebSettingssettings=webView.getSettings();
  4.  
  5. settings.setJavaScriptEnabled(true);
  6.  
  7. settings.setDomStorageEnabled(true);
  8.  
  9. settings.setDatabasePath("/data/data/my.package/folder");
  10.  
  11. webView.setWebChromeClient(newWebChromeClient()
  12.  
  13. {@OverridepublicbooleanonConsoleMessage(ConsoleMessagemsg){
  14. //pipethistoLogCat
  15. }});
  16.  
  17. webView.addJavascriptInterface(newMyInterface(),"zorro");
  18.  
  19. webView.loadUrl("javascript:tarzan.start()");

URL: http://www.slideshare.net/mobile/michael.galpin/android-lessons-you-wont-learn-in-school

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.