You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/11/21 23:01:16 UTC

[2/2] docs commit: Updated the Android WebView code docs with more helpful snippets

Updated the Android WebView code docs with more helpful snippets


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/commit/61029206
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/tree/61029206
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/diff/61029206

Branch: refs/heads/master
Commit: 61029206f35bce9776923508253c6b5f16191943
Parents: 6356698
Author: Joe Bowser <bo...@apache.org>
Authored: Wed Nov 21 13:58:40 2012 -0800
Committer: Joe Bowser <bo...@apache.org>
Committed: Wed Nov 21 13:58:40 2012 -0800

----------------------------------------------------------------------
 docs/en/edge/guide/cordova-webview/android.md |   53 ++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/61029206/docs/en/edge/guide/cordova-webview/android.md
----------------------------------------------------------------------
diff --git a/docs/en/edge/guide/cordova-webview/android.md b/docs/en/edge/guide/cordova-webview/android.md
index 6618ccd..747a130 100644
--- a/docs/en/edge/guide/cordova-webview/android.md
+++ b/docs/en/edge/guide/cordova-webview/android.md
@@ -62,5 +62,58 @@ Guide to using CordovaWebView in an Android Project
                 cwv.loadUrl("file:///android_asset/www/index.html");
             }
 
+In addition to this, if you are using camera, you will want to implement this as well:
+
+    @Override
+    public void setActivityResultCallback(CordovaPlugin plugin) {
+        this.activityResultCallback = plugin;        
+    }
+    /**
+     * Launch an activity for which you would like a result when it finished. When this activity exits, 
+     * your onActivityResult() method will be called.
+     *
+     * @param command           The command object
+     * @param intent            The intent to start
+     * @param requestCode       The request code that is passed to callback to identify the activity
+     */
+    public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) {
+        this.activityResultCallback = command;
+        this.activityResultKeepRunning = this.keepRunning;
+
+        // If multitasking turned on, then disable it for activities that return results
+        if (command != null) {
+            this.keepRunning = false;
+        }
+
+        // Start activity
+        super.startActivityForResult(intent, requestCode);
+    }
+
+    @Override
+    /**
+     * Called when an activity you launched exits, giving you the requestCode you started it with,
+     * the resultCode it returned, and any additional data from it.
+     *
+     * @param requestCode       The request code originally supplied to startActivityForResult(),
+     *                          allowing you to identify who this result came from.
+     * @param resultCode        The integer result code returned by the child activity through its setResult().
+     * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
+     */
+    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
+        super.onActivityResult(requestCode, resultCode, intent);
+        CordovaPlugin callback = this.activityResultCallback;
+        if (callback != null) {
+            callback.onActivityResult(requestCode, resultCode, intent);
+        }
+    }
+
+Finally, remember to add the thread pool, otherwise the plugins will have no threads to run on.
+
+
+    @Override
+    public ExecutorService getThreadPool() {
+        return threadPool;
+    }
+
 6. Copy your application's HTML and JavaScript used to the `/assets/www` directory of your Android project
 7. Copy `cordova.xml` and `plugins.xml` from `/framework/res/xml` to the `/res/xml` folder in your project