android - From Html To Native -


i write example html native,but can't jump. here code. h5activity(html)

webview = (webview) findviewbyid(r.id.webview);         webview.loadurl("file:///android_asset/hello.html");         webview.addjavascriptinterface(new object()         {             @javascriptinterface             public void jump()             {                 intent intent = new intent(h5activity.this, nativebactivity.class);                 startactivity(intent);             }         }, "egos"); 

nativebactivity(native)

setcontentview(r.layout.activity_nativea); button = (button) findviewbyid(r.id.text); button.settext("finish"); 

my hello.html

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">  <html>     <head>         <meta http-equiv="content-type" content="text/xhtml; charset=utf-8" />          <script type="text/javascript">         function flea(){             // if(egos){                 egos.jump("hello");             // }         }         </script>     </head>     <body>         <p><button onclick="egos.jump()">jump native</button></p>     </body> </html> 

but doesn't jump.i try bes. can me?

i think need enable javascript in webview.

websettings websettings = webview.getsettings(); websettings.setjavascriptenabled(true); 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -