l***@live.com
l***@live.com
  • 发布:2019-05-29 15:50
  • 更新:2019-05-29 19:40
  • 阅读:909

【报Bug】SDK.obatinFirstPage(app).obtainWebview()引发页面无限刷新

分类:5+ SDK

详细问题描述

使用 mWebview = SDK.obatinFirstPage(app).obtainWebview(); 获取webview对象,但是SDK让webview重新刷新了。

[内容]

按照“SDK_骁骑”给出的方案(见 http://ask.dcloud.net.cn/question/18516),
尝试获取webview对象来实现Java和JS之间的交互。

[步骤]
1,使用 mWebview = SDK.obatinFirstPage(app).obtainWebview(); 获取webview对象;
2,真机调试,webview 不断的无限刷新,一直在splash页和启动页迅速切换;

[结果]
1,这是我的截图:

2,这是论坛上搜到的其他用户碰到同样问题后给的截图(见 http://ask.dcloud.net.cn/question/53897):

[期望]

1,能获取到webview;
2,App正常运行,不会无限刷新。

IDE运行环境说明

[IDE版本号]
Android Studio 3.2

[windows版本号]
Win7

App运行环境说明

[Android版本号]
Android 7.0

[手机型号]

[可重现代码片段]

@Override  
public void onCoreInitEnd(ICore coreHandler) {  

    // 表示Webapp的路径  
    String appBasePath = "/apps/UHFReader";  

    // 设置启动参数,必须是字符串格式的JSON对象。可在页面中通过plus.runtime.arguments;方法获取到传入的参数  
    // 在H5+应用的Js中,可以用JSON.parse(plus.runtime.arguments)去获取并转化为一个Js对象。  
    String args = "{url:'http://www.baidu.com'}";  

    // 启动独立应用的5+ Webapp  
    app = SDK.startWebApp(activity, appBasePath, args, new IWebviewStateListener() {  
        // 设置Webview事件监听,可在监听内获取WebIvew加载内容的进度  
        @Override  
        public Object onCallBack(int pType, Object pArgs) {  
            switch (pType) {  
                case IWebviewStateListener.ON_WEBVIEW_READY:  
                    // WebApp准备加载事件  
                    // 准备完毕之后添加webview到显示父View中,  
                    // 设置排版不显示状态,避免显示webview时html内容排版错乱问题  
                    View view = ((IWebview) pArgs).obtainApp().obtainWebAppRootView().obtainMainView();  
                    view.setVisibility(View.INVISIBLE);  
                    rootView.addView(view, 0);  
                    break;  
                case IWebviewStateListener.ON_PAGE_STARTED:  
                    // 首页面开始加载事件  
                    pd = ProgressDialog.show(activity, "加载中", "0/100");  
                    break;  
                case IWebviewStateListener.ON_PROGRESS_CHANGED:  
                    // WebApp首页面加载进度变化事件  
                    if (pd != null) {  
                        pd.setMessage(pArgs + "/100");  
                    }  
                    break;  
                case IWebviewStateListener.ON_PAGE_FINISHED:  
                    // WebApp首页面加载完成事件  
                    if (pd != null) {  
                        pd.dismiss();  
                        pd = null;  
                    }  
                    // 页面加载完毕,设置显示webview  
                    // 如果不需要显示spalsh页面将此行代码移动至onCloseSplash事件内  
                    app.obtainWebAppRootView().obtainMainView().setVisibility(View.VISIBLE);  
                    try{  

                        ***mWebView = (WebView) SDK.obatinFirstPage(app).obtainWebview();***  

                    }catch (Exception e){  
                        Log.e("================>",e.toString());  
                    }  
                    break;  
            }  
            return null;  
        }  
    }, this);  

    // 设置APP运行事件监听  
    app.setIAppStatusListener(new IAppStatusListener() {  
        @Override  
        public String onStoped(boolean b, String s) {  
            return null;  
        }  

        @Override  
        public boolean onStop() {  
            // 应用运行停止时调用  
            rootView.removeView(app.obtainWebAppRootView().obtainMainView());  
            // TODO Auto-generated method stub  
            return false;  
        }  

        @Override  
        public void onStart() {  
            // 独立应用启动时触发事件          
        }  

        @Override  
        public void onPause(IApp arg0, IApp arg1) {  
            // WebApp暂停运行时触发事件  
        }  
    });  
}  

联系方式

[QQ]
1713892501

2019-05-29 15:50 负责人:无 分享
已邀请:
DCloud_Android_zl

DCloud_Android_zl

通过SDK类的obtainAllIWebview()方法获取当前打开的所有IWebView对象。

该问题目前已经被锁定, 无法添加新回复