Crosswalk+Cordova¿ª·¢°²×¿appÖ® java scriptµ÷ÓÃjava £¨¸½Ô´´úÂëÏÂÔØ £©
?
?
¶¨Òåjs»Øµ÷½Ó¿Ú
?
/**
* js»Øµ÷½Ó¿Ú
*
* @author graceup
*
*/
public class JsInterface {
public JsInterface() {
}
@java scriptInterface
public String sayHello() {
// TODO do more thing
return Hello World!;
}
} ±¸×¢£ºÕâÀïµÄ @java scriptInterface ËùÔڵİüÊÇ import org.xwalk.core.java scriptInterface; ?
XWalkViewÉèÖÃjava script¿ÉÓÃÇҰ󶨶ÔÏó
setContentView(R.layout.activity_main);
mXWalkView = (XWalkView) findViewById(R.id.activity_main);
//°ó¶¨
mXWalkView.addjava scriptInterface(new JsInterface(), NativeInterface);
mXWalkView.load(file:///android_asset/www/index.html, null); ?
µ÷ÓÃhtmlÖ´ÐÐjava script»òÖ±½ÓÖ´ÐÐjava scriptµ÷ÓÃJava
mXWalkView.load(file:///android_asset/www/index.html, null); index.htmlÔ´Âë £º
button
<script>
function clicked() {
alert(NativeInterface.sayHello());
}
?
?
?