I have extended CordovaActivity
, and implemented WLInitWebFrameworkListener
plus BluetoothAdapter.LeScanCallback
in native code
public class MainActivity extends CordovaActivity implements WLInitWebFrameworkListener, BluetoothAdapter.LeScanCallback{
Inside this class I have implemented
@Override public void onInitWebFrameworkComplete(WLInitWebFrameworkResult arg0) { // if a device is connected launch application if(mConnectedGATT.connect()){ WL.getInstance().addActionReceiver(new ErosReceiver()); super.loadUrl(WL.getInstance().getMainHtmlFilePath()); } else{Log.i(TAG, "Could not connect");} }
I have added the following to main.js in a function
WL.App.SendActionToNative ("ReqSlaveList", data);
I have created another class
MyReceiver
public class MyReceiver implements WLActionReceiver {
Implemented
public void onActionReceived(String action, JSONObject data)
Now it seems like the OnActionReceived
never gets called.
I don't think you're supposed to create a new class that implements
onInitWebFrameworkComplete
. You need to append your code to the existing application main class that already does this (and which MobileFirst Platform relies on).You can find this application main class in your application's native folder in MobileFirst Studio. That is where you should declare your
ActionReceiver
. See here: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/6.3/adding-native-functionality/android-adding-native-ui-elements-hybrid-applications/#action-receiver