Android - Using native pages
This tutorial explains how to integre native and web "pages" in an Android application by using the
This tutorial covers the following topics:
- Creating a native page
- Returning control to the web view
- Sample application
- Implement the
WL.NativePage.show()method to open the native page:
nativePageClassName: The name of a native Android class to start.
backFromNativePage: A callback function to call when the native page closes.
params: An optional custom parameters object to pass to the native code.
- To handle the callback function:
backFromNativePage(data)function passes data back to the web part of an application after the native page closes.
Creating a native page
In Android, the native page must be implemented as an Android Activity, or extend an existing Activity.
- Declare the native page in the
AndroidManifest.xmlfile, as you would any Activity. For example:
- To retrieve custom data parameters that are passed from the web view, use an
Returning control to the web view
When the native page switches back to the web view, the
finish() function is called for the Activity.
You can pass data back to the web view by using an
Intent object. For example:
Click to download the MobileFirst project.