首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cordovawebview sendjavascript已弃用

Cordovawebview sendjavascript已弃用
EN

Stack Overflow用户
提问于 2015-04-30 22:24:12
回答 1查看 2.1K关注 0票数 3

Cordova Web View sendjavascript已被弃用,它不适用于我。我的java代码是:

代码语言:javascript
复制
public static void sendJavascript(JSONObject _json) {
    String _d = "javascript:" + gECB + "(" + _json.toString() + ")";
    Log.v(TAG, "sendJavascript: " + _d);
    Log.i(TAG,_d);
    if (gECB != null && gWebView != null) {
        gWebView.sendJavascript(_d);//deprecated method
    }
}

我的java脚本代码:

代码语言:javascript
复制
document.addEventListener("deviceready", function(){

       window.plugins.pushNotification.register(successHandler, errorHandler, {
            ecb      : 'onNotificationGCM',
            senderID : 'xxxxxxxxxxxxx'
        });

    // Method to handle device registration for Android.
        var onNotificationGCM = function(e) {
            if('registered' === e.event) {
                // Successfully registered device.
                alert(e.regid);
            }
            else if('error' === e.event) {
                // Failed to register device.
                alert(e.msg);
            }
            else if('message' === e.event) {
                //mesage recived 
                alert(e.payload.message);
            }

        };


        // result contains any message sent from the plugin call
        function successHandler (result) {
            alert('gcm result = ' + result);
        }

        // result contains any error description text returned from the plugin call
        function errorHandler (error) {
            alert('error = ' + error);
        }   
    });

不推荐使用的详细信息:https://apache.googlesource.com/cordova-android/+/3.6.1/framework/src/org/apache/cordova/CordovaWebView.java

请帮帮我?

EN

回答 1

Stack Overflow用户

发布于 2016-04-05 23:32:07

这对你来说应该是可行的:gWebView.loadUrl("javascript:myJavaScriptFuntion();");

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29970350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档