Android - Using native pagesimprove this page | report issue
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.
Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.