ÔÉúactivityºÍh5½»»¥°¸Àý.zip
void runJs(function code)h5Ö´ÐÐapp JS½Å±¾
window.at.runJs(function (){
printl("ÄãºÃ");
auto.home();
}.toString());
void runJsFile(String file) H5ÔËÐÐAPP JSÎļþ
window.at.runJsFile('Ö÷½Å±¾.js');
void callFunction£¨String funname,String arg) H5Ö´Ðнű¾·½·¨
window.at.callFun('main',"hello");
String getRootPath() »ñÈ¡ÏîÄ¿¸ùĿ¼
window.at.getRootPath();
String getResourcesPath() »ñÈ¡ÏîÄ¿×ÊԴĿ¼
window.at.getResourcesPath();
void setConfig(String path,String arg,String value) ´æ´¢Êý¾Ý
path:´æ´¢Â·¾¶,ÀýÈç/sdcard/1.txt;
arg:²ÎÊý
value:´æ´¢Öµ
window.at.setConfig('/sdcard/1.txt','a','1');
let res=window.at.getResourcesPath();
window.at.setConfig(res+'1.txt','a','1');
String getConfig(String path,String arg,String value) ¶ÁÈ¡Êý¾Ý
path:´æ´¢Â·¾¶,ÀýÈç/sdcard/1.txt;
arg:²ÎÊý
value:ĬÈÏÖµ,ûÓÐÊý¾ÝµÄÇé¿öÏÂĬÈÏ·µ»Ø
window.at.getConfig('/sdcard/1.txt','a','1');
let res=window.at.getResourcesPath();
window.at.getConfig(res+'1.txt','a','1');
publicSet(String key,String value) ¹«¹²±äÁ¿´«²Î
window.at.publicSet('a','1');
publicData.get('a')
publicGet(String key) ¹«¹²±äÁ¿¶Á²Î
window.at.publicGet('a');
publicData.set('a','1')
ÍêÕûHTML°¸Àý
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>·½Ê½Ò»</title>
<script language="JavaScript">
function test() {
window.at.runJs(function (){
printl("ÄãºÃ");
}.toString());
}
</script>
</head>
<body>
<input type="Button" width="300" value="Æô¶¯½Å±¾" onClick="test()" />
</body>
</html>
APPµ÷ÓÃH5:
Ê×ÏÈ»ñÈ¡web¿Ø¼þ,ÀýÈçweb¿Ø¼þµÄ×Ô¶¨ÒåIDÊÇweb
var ac = new activity();
ac.loadXML(`
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android
rientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="H5ÑÝʾ"
android:textSize="18sp"
android:textStyle="bold"
android:gravity="center"
android:paddingBottom="8dp" />
<WebView
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
`)
sleep.millisecond(ºÁÃë = 400);
var web1 = ac.findWebViewById('web');
¼ÓÔØÍøÖ·loadUrl(url)
¸´ÖÆweb1.url('/´úÂë/h5.html');
Ö´ÐÐh5µÄjs·½·¨£¬×¢Òâ´úÂëÊÂ×Ö·û´®http://bbs.aiwork24.com/thread-124-1-1.html
String runWebJs(String jscode)
·µ»ØÖµ:ÀàËÆjsÖÐevalÖ´ÐÐjs´úÂëµÄ·µ»ØÖµ£¬Ò»°ãÊÇ·µ»Ø×îºóÒ»¸ö±äÁ¿µÄÖµhttp://www.postbbs.com/thread-2894-1-1.html
web1.runWebJs(`alert("123")`);