Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3B14918F71 for ; Tue, 15 Mar 2016 23:13:11 +0000 (UTC) Received: (qmail 68808 invoked by uid 500); 15 Mar 2016 23:13:11 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 68766 invoked by uid 500); 15 Mar 2016 23:13:11 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 68745 invoked by uid 99); 15 Mar 2016 23:13:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Mar 2016 23:13:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8DB86DFA42; Tue, 15 Mar 2016 23:13:10 +0000 (UTC) From: riknoll To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-docs pull request: CB-9393: Documenting how to embed a Sys... Content-Type: text/plain Message-Id: <20160315231310.8DB86DFA42@git1-us-west.apache.org> Date: Tue, 15 Mar 2016 23:13:10 +0000 (UTC) Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-docs/pull/544#discussion_r56257379 --- Diff: www/docs/en/dev/guide/platforms/android/webview.md --- @@ -29,106 +29,86 @@ components can communicate with each other, see Application Plugins. If you're unfamiliar with Android, you should first familiarize yourself with the [Android Platform Guide](index.html) and have the latest Android SDK installed before you attempt the more unusual development option -of embedding a WebView. Starting with Cordova 1.9, the Android -platform relies on a `CordovaWebView` component, which builds on a -legacy `CordovaActivity` component that pre-dates the 1.9 release. +of embedding a WebView. Starting with Cordova 4.0, the Android +platform relies on a `SystemWebView` component. 1. To follow these instructions, make sure you have the latest Cordova distribution. Download it from [cordova.apache.org](http://cordova.apache.org) and unzip its Android package. -1. Navigate to the Android package's `/framework` directory and run - `ant jar`. It creates the Cordova `.jar` file, formed as - `/framework/cordova-x.x.x.jar`. +1. Create a project in Android Studio -1. Copy the `.jar` file into the Android project's `/libs` directory. +1. Copy the framework directory into your project's root directory and name it +CordovaLib + +1. Add CordovaLib in your settings.gradle file + +include ':app', ':CordovaLib' + +1. Add that project as a library project to your main project. This can be done in your application's build.gradle file found in +app/build.gradle: + + dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:21.0.3' + //Add Cordova below + debugCompile project(path: ":CordovaLib", configuration: "debug") + releaseCompile project(path: ":CordovaLib", configuration: "release") + } 1. Add the following to the application's `/res/xml/main.xml` file, with the `layout_height`, `layout_width` and `id` modified to suit the application: - -1. Modify the activity so that it implements the `CordovaInterface`. - It should implement the included methods. You may wish to copy - them from `/framework/src/org/apache/cordova/CordovaActivity.java`, - or else implement them on your own. The following code fragment - shows a basic application that relies on the interface. Note how - the referenced view id matches the `id` attribute specified in the - XML fragment shown above: - - public class CordovaViewTestActivity extends Activity implements CordovaInterface { - CordovaWebView cwv; - /* Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - cwv = (CordovaWebView) findViewById(R.id.tutorialView); - Config.init(this); - cwv.loadUrl(Config.getStartUrl()); - } +1. Add the following code to setup your Activity so that you have an interface -1. If the application needs to use the camera, implement the - following: + private CordovaInterfaceImpl iface = new CordovaInterfaceImpl(this); + +1. Add the following to intialize the WebView + + //Set up the webview + ConfigXmlParser parser = new ConfigXmlParser(); + parser.parse(this); + + SystemWebView webView = (SystemWebView) findViewById(R.id.tutorialView); + webInterface = new CordovaWebViewImpl(new SystemWebViewEngine(webView)); + webInterface.init(iface, parser.getPluginEntries(), parser.getPreferences()); + + webView.loadUrl(parser.getLaunchUrl()); + + +1. Copy the application's HTML and JavaScript files to the Android + project's `app/src/main/assets/www` directory. + +1. Copy the `config.xml` file from `/framework/res/xml` to the --- End diff -- I found config.xml to be in `bin/templates/project/res/xml` --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org For additional commands, e-mail: dev-help@cordova.apache.org