下面是代码:
mui.init();
mui.plusReady();
document.addEventListener("plusready", function() {
// 扩展API加载完毕,现在可以正常调用扩展API
// 导入android.content.Intent类对象\
try {
var WindowManager = plus.android.importClass("android.view.WindowManager");
var PixelFormat = plus.android.importClass("android.graphics.PixelFormat");
var Gravity = plus.android.importClass("android.view.Gravity");
var main = plus.android.runtimeMainActivity();
var appContext = plus.android.invoke(main, "getApplicationContext");
var mWindowManager = plus.android.invoke(appContext, "getSystemService", "window");
var w = plus.webview.create("https://www.baidu.com","https://www.baidu.com",{},{preload:'preload webview'});
w.show();
var webView = w.nativeInstanceObject();
var mLayout = new WindowManager.LayoutParams();
plus.android.setAttribute(mLayout, "type", WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
plus.android.setAttribute(mLayout, "flags", WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
plus.android.setAttribute(mLayout, "format", PixelFormat.TRANSLUCENT);
plus.android.setAttribute(mLayout, "gravity", Gravity.TOP | Gravity.LEFT);
plus.android.setAttribute(mLayout, "width", 140);
plus.android.setAttribute(mLayout, "height", 140);
plus.android.setAttribute(mLayout, "x", 0);
plus.android.setAttribute(mLayout, "y", 0);
alert(webView);
alert(mLayout);
plus.android.invoke(mWindowManager, "addView", webView, mLayout);
} catch(e) {
console.log(e);
alert(e);
}
}, false);
1 个回复
l***@163.com
你好 你的这个解决了吗?