Commit e4639908 by PKnittel

Fixed webView-Problems with cordova-android 4.0

parent d8d62068
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
package de.appplant.cordova.plugin.localnotification; package de.appplant.cordova.plugin.localnotification;
import android.app.Activity;
import android.os.Build; import android.os.Build;
import org.apache.cordova.CallbackContext; import org.apache.cordova.CallbackContext;
...@@ -34,6 +35,7 @@ import org.json.JSONArray; ...@@ -34,6 +35,7 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -557,16 +559,18 @@ public class LocalNotification extends CordovaPlugin { ...@@ -557,16 +559,18 @@ public class LocalNotification extends CordovaPlugin {
eventQueue.add(js); eventQueue.add(js);
return; return;
} }
Runnable jsLoader = new Runnable() {
webView.post(new Runnable(){ public void run() {
public void run(){ webView.loadUrl("javascript:" + js);
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);
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment