CB-6851 Deprecate WebView.sendJavascript()
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/b4076410 Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/b4076410 Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/b4076410 Branch: refs/heads/master Commit: b40764104958e5b8a4c7ef19ae98d3a83be17810 Parents: 32e07c2 Author: Andrew Grieve <[email protected]> Authored: Sun Jun 8 22:47:41 2014 -0400 Committer: Andrew Grieve <[email protected]> Committed: Sun Jun 8 22:47:41 2014 -0400 ---------------------------------------------------------------------- .../src/org/apache/cordova/CordovaWebView.java | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b4076410/framework/src/org/apache/cordova/CordovaWebView.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 9e98ac6..bb51a7a 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -557,10 +557,25 @@ public class CordovaWebView extends WebView { /** * Send JavaScript statement back to JavaScript. - * (This is a convenience method) - * - * @param statement + * Deprecated (https://issues.apache.org/jira/browse/CB-6851) + * Instead of executing snippets of JS, you should use the exec bridge + * to create a Java->JS communication channel. + * To do this: + * 1. Within plugin.xml (to have your JS run before deviceready): + * <js-module><runs/></js-module> + * 2. Within your .js (call exec on start-up): + * require('cordova/channel').onCordovaReady.subscribe(function() { + * require('cordova/exec')(win, null, 'Plugin', 'method', []); + * function win(message) { + * ... process message from java here ... + * } + * }); + * 3. Within your .java: + * PluginResult dataResult = new PluginResult(PluginResult.Status.OK, CODE); + * dataResult.setKeepCallback(true); + * savedCallbackContext.sendPluginResult(dataResult); */ + @Deprecated public void sendJavascript(String statement) { this.jsMessageQueue.addJavaScript(statement); }
