-2

I have a mobilefirst hybrid app project and I have implemented Activity subclass in its native project for bluetooth and google maps. Now if I run on a physical device, only the native activity launches and no html page is displayed. On the other hand if i try to run it on the emulator, the html pages are displayed but cant test the native side. (native activity searches for bluetooth)

Samra
  • 1,815
  • 4
  • 35
  • 71

1 Answers1

0

You need to use the SendAction API to invoke native classes from the web code. See the following tutorial and documentation topic:

Using the API you can make a call in wlCommonInit to execute your code in the native class and use that native functionality in your hybrid app.

Alternatively you can also implement a custom Cordova plug-in: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/adding-native-functionality/android-adding-native-functionality-hybrid-application-apache-cordova-plugin/

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • OK so the part i was missing is that I needed to implement WLInitWebFrameworkListener class and implement its onInitWebFrameworkComplete function to load mainhtmlfile, so now i can see my html side on the app. Now what I want to do is initialize this framework on a listview item click event, but it doesnot let me since the context has changed – Samra Jul 05 '16 at 03:07
  • I had to add MyActivity.this instead of this to change the context!! Problem solved – Samra Jul 05 '16 at 03:21