1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <html>
- <header>
- <script src="apkloader.js"></script>
- </header>
- <body style="background: #292929;">
- <div id="divTest" style="color: #fff;">557766</div>
- <button onclick="sayNativeHello()">回显C++和111</button>
- <div id="bb" style="height: 50px;"></div>
- <button onclick="startPicActivity()">选择图片</button>
- <div id="aa" style="height: 50px;"></div>
- <input id="txtA" value="5"></input> <input id="txtB" value="6"></input>
- <div style="height: 4px;"></div>
- <button id="btnSum" onclick="bindService()">绑定Service并计算上边两个数之和</button>
- <div id="cc" style="height: 50px;"></div>
- <button onclick="unbindService()">解绑Service</button>
- <div id="dd" style="height: 50px;"></div>
- <button onclick="startActivity()">启动Activity</button>
- <div id="ee" style="height: 50px;"></div>
- <button onclick="back()">返回</button>
- </body>
- <script>
- ApkLoader.setPackageName("com.example.plugina");
- function sayNativeHello(){
- ApkLoader.call("sayHello", {"name": "1111"});
- }
- function bindService(){
- let a = document.getElementById("txtA").value;
- let b = document.getElementById("txtB").value;
- alert(a + b);
- ApkLoader.call("bindService", {"a": a, "b": b});
- }
- function unbindService(){
- ApkLoader.call("unbindService", {"name": "1111"});
- }
- function startActivity(){
- ApkLoader.call("startActivity", {"name": "1111"});
- }
- function com_example_navitetest_sayNativeHelloEcho(msg){
- document.getElementById("divTest").innerHTML = msg.msg;
- }
- function startPicActivity(){
- ApkLoader.call("startPicActivity", {});
- }
- function back(){
- window.parent.frameUtil.hideIframe('CJJARSO')
- }
- ApkLoader.setEcho("sayNativeHelloEcho", com_example_navitetest_sayNativeHelloEcho);
-
-
- window.addEventListener('message', (event) => {
- const data = event.data
- if (!Array.isArray(data)) return
- const [code, argsJson] = data
- if (code === 'apkLoaderEcho' && ApkLoader && ApkLoader.echo){
- const args = JSON.parse(argsJson);
- ApkLoader.echo(...args);
- return;
- }
- if (code !== 'lowcode') return
- const args = JSON.parse(argsJson);
- cordova.callbackFromNative(...args);
- })
- </script>
- </html>
|