Loading src/android/LocalNotification.java +16 −0 Changes for src/android/LocalNotification.java: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ package de.appplant.cordova.plugin.localnotification; import java.util.ArrayList; import java.util.Map; import java.util.Set; Loading Loading @@ -53,12 +54,16 @@ public class LocalNotification extends CordovaPlugin { protected static CordovaWebView webView = null; protected static Context context = null; protected static ArrayList<String> callbackQueue = new ArrayList<String>(); @Override public void initialize (CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); LocalNotification.webView = super.webView; LocalNotification.context = super.cordova.getActivity().getApplicationContext(); execPendingCallbacks(); } @Override Loading Loading @@ -240,4 +245,15 @@ public class LocalNotification extends CordovaPlugin { protected static NotificationManager getNotificationManager () { return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); } /** * Calls all pending callbacks after the webview was created. */ private void execPendingCallbacks () { for (String js : callbackQueue) { webView.sendJavascript(js); } callbackQueue.clear(); } } src/android/ReceiverActivity.java +1 −9 Changes for src/android/ReceiverActivity.java: 1 added line, 9 removed lines. Original line number Diff line number Diff line Loading @@ -21,9 +21,6 @@ package de.appplant.cordova.plugin.localnotification; import java.util.Timer; import java.util.TimerTask; import org.json.JSONException; import org.json.JSONObject; Loading Loading @@ -80,12 +77,7 @@ public class ReceiverActivity extends Activity { // after reboot, LocalNotification.webView is always null // call background callback later if (LocalNotification.webView == null) { new Timer().schedule(new TimerTask() { @Override public void run() { LocalNotification.webView.sendJavascript(js); } }, 4000); LocalNotification.callbackQueue.add(js); } else { LocalNotification.webView.sendJavascript(js); } Loading Loading
src/android/LocalNotification.java +16 −0 Changes for src/android/LocalNotification.java: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ package de.appplant.cordova.plugin.localnotification; import java.util.ArrayList; import java.util.Map; import java.util.Set; Loading Loading @@ -53,12 +54,16 @@ public class LocalNotification extends CordovaPlugin { protected static CordovaWebView webView = null; protected static Context context = null; protected static ArrayList<String> callbackQueue = new ArrayList<String>(); @Override public void initialize (CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); LocalNotification.webView = super.webView; LocalNotification.context = super.cordova.getActivity().getApplicationContext(); execPendingCallbacks(); } @Override Loading Loading @@ -240,4 +245,15 @@ public class LocalNotification extends CordovaPlugin { protected static NotificationManager getNotificationManager () { return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); } /** * Calls all pending callbacks after the webview was created. */ private void execPendingCallbacks () { for (String js : callbackQueue) { webView.sendJavascript(js); } callbackQueue.clear(); } }
src/android/ReceiverActivity.java +1 −9 Changes for src/android/ReceiverActivity.java: 1 added line, 9 removed lines. Original line number Diff line number Diff line Loading @@ -21,9 +21,6 @@ package de.appplant.cordova.plugin.localnotification; import java.util.Timer; import java.util.TimerTask; import org.json.JSONException; import org.json.JSONObject; Loading Loading @@ -80,12 +77,7 @@ public class ReceiverActivity extends Activity { // after reboot, LocalNotification.webView is always null // call background callback later if (LocalNotification.webView == null) { new Timer().schedule(new TimerTask() { @Override public void run() { LocalNotification.webView.sendJavascript(js); } }, 4000); LocalNotification.callbackQueue.add(js); } else { LocalNotification.webView.sendJavascript(js); } Loading