Skip to content

Commit a22eff8

Browse files
apacheGH-884 android: Embedding Android WebView doc looks broken
The documentation of embedding cordova in native apps is outdated and this updated is considered as a quick update.
1 parent 6dc8836 commit a22eff8

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

www/docs/en/dev/guide/platforms/android/webview.md

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,53 +38,57 @@ legacy `CordovaActivity` component that pre-dates the 1.9 release.
3838
[cordova.apache.org](http://cordova.apache.org) and unzip its
3939
Android package.
4040

41-
2. Follow the instructions here to build your first cordova app [CreateYourFirstApp](https://cordova.apache.org/docs/en/8.x/guide/cli/index.html)
41+
1. Follow the instructions here to build your first cordova app [CreateYourFirstApp](https://cordova.apache.org/docs/en/8.x/guide/cli/index.html)
4242

43-
3. Copy Cordova framework files **from platforms/android/CordovaLib/src/** to your android application directory at **/app/main/java**. Also copy additional Cordova framework files **from platforms/android/src/** to your android application directory at **/app/main/java**.
43+
1. Copy Cordova framework files
44+
```
45+
platforms/android/CordovaLib/src/.* to <AndroidAppRoot>/app/main/java
46+
platforms/android/src/** to <AndroidAppRoot>/app/main/java
47+
```
4448

45-
4. Modify the layout file of the activity that shall host the Cordova view e.g.
49+
1. Modify the layout file of the activity that shall host the Cordova view e.g.
4650
```
47-
<LinearLayout android:layout_width="fill_parent"
51+
<LinearLayout android:layout_width="fill_parent"
4852
android:layout_height="fill_parent"
4953
android:orientation="vertical"
5054
xmlns:android="http://schemas.android.com/apk/res/android">
51-
<org.apache.cordova.engine.SystemWebView
52-
android:id="@+id/cordovaWebView"
53-
android:layout_width="match_parent"
54-
android:layout_height="match_parent" />
55-
</LinearLayout
55+
<org.apache.cordova.engine.SystemWebView
56+
android:id="@+id/cordovaWebView"
57+
android:layout_width="match_parent"
58+
android:layout_height="match_parent" />
59+
</LinearLayout
5660
```
57-
5. Modify your activity so that the class extends CordovaActivity (found at app/main/java/org/apache/....CordovaActivity.java)
61+
1. Modify your activity so that the class extends CordovaActivity (found at app/main/java/org/apache/....CordovaActivity.java)
5862
```
59-
public class TestActivity extends CordovaActivity {
63+
public class TestActivity extends CordovaActivity {
6064
61-
}
65+
}
6266
```
6367

64-
6. Override onCreate, makeWebView and createViews to use your defined layout
68+
1. Override onCreate, makeWebView and createViews to use your defined layout
6569
```
66-
@Override
67-
public void onCreate(Bundle savedInstanceState) {
68-
super.onCreate(savedInstanceState);
69-
setContentView(R.layout.activity_test); //this is the layout file for your activity
70-
super.init();
71-
loadUrl(launchUrl);
72-
}
70+
@Override
71+
public void onCreate(Bundle savedInstanceState) {
72+
super.onCreate(savedInstanceState);
73+
setContentView(R.layout.activity_test); //this is the layout file for your activity
74+
super.init();
75+
loadUrl(launchUrl);
76+
}
7377
74-
@Override
75-
protected CordovaWebView makeWebView() {
76-
SystemWebView appView = (SystemWebView) findViewById(R.id.cordovaWebView); //this is the id for the SystemWebView in step 4
77-
return new CordovaWebViewImpl(new SystemWebViewEngine(appView));
78-
}
78+
@Override
79+
protected CordovaWebView makeWebView() {
80+
SystemWebView appView = (SystemWebView) findViewById(R.id.cordovaWebView); //this is the id for the SystemWebView in step 4
81+
return new CordovaWebViewImpl(new SystemWebViewEngine(appView));
82+
}
7983
80-
@Override
81-
protected void createViews() {
82-
// leave empty so the layout is used
83-
}
84+
@Override
85+
protected void createViews() {
86+
// leave empty so the layout is used
87+
}
8488
```
8589

86-
7. Copy the application's HTML and JavaScript files to the Android
90+
1. Copy the application's HTML and JavaScript files to the Android
8791
project's `/assets/www` directory.
8892

89-
8. Copy the `config.xml` file from `/res/xml` to the
93+
1. Copy the `config.xml` file from `/res/xml` to the
9094
project's `/res/xml` directory.

0 commit comments

Comments
 (0)