Commit e4639908 authored by PKnittel's avatar PKnittel
Browse files

Fixed webView-Problems with cordova-android 4.0

parent d8d62068
Loading
Loading
Loading
Loading
+10 −6
Changes for src/android/LocalNotification.java: 10 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

package de.appplant.cordova.plugin.localnotification;

import android.app.Activity;
import android.os.Build;

import org.apache.cordova.CallbackContext;
@@ -34,6 +35,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

@@ -557,16 +559,18 @@ public class LocalNotification extends CordovaPlugin {
            eventQueue.add(js);
            return;
        }

        webView.post(new Runnable(){
        Runnable jsLoader = new Runnable() {
            public void run() {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                    webView.evaluateJavascript(js, null);
                } else {
                webView.loadUrl("javascript:" + js);
            }
        };
        try {
            Method post = webView.getClass().getMethod("post",Runnable.class);
            post.invoke(webView,jsLoader);
        } catch(Exception e) {

            ((Activity)(webView.getContext())).runOnUiThread(jsLoader);
        }
        });
    }

    /**