Dear Experts,
I'm trying to create an extension for native android Bluetooth functionalities, I. have created Extension plugin and I'm directly calling the java class methods by importing from "@nativescript/core/application"; not created the .aar files.
Only isEnabled() is working fine with the BluetoothAdapter.ACTION_REQUEST_ENABLE intent parameter.
Others like
1. discovering device through registerBroadcastReceiver call back methods with ACTION_FOUND
2. getBondedDevices() are not working as expected.
paired devices or scanning the devices are not returning the device details.
Can you please help me to understand how can we use native android Bluetooth class methods. I have attached the code snippet for your reference.
androidApp.registerBroadcastReceiver(
android.bluetooth.BluetoothAdapter.ACTION_STATE_CHANGED,
(context, intent) => {
const state = intent.getIntExtra(android.bluetooth.BluetoothAdapter.EXTRA_STATE, android.bluetooth.BluetoothAdapter.ERROR);
if(android.bluetooth.BluetoothAdapter.STATE_ON) {
const adapter = android.bluetooth.BluetoothAdapter.getDefaultAdapter();
let BTPairSet = adapter.getBondedDevices();
//alert(JSON.stringify(BTPairSet));
var setToObject = Object.assign({}, ...Array.from(BTPairSet));
//alert(JSON.stringify(setToObject));
Thanks,
Krishna
Request clarification before answering.
| User | Count |
|---|---|
| 13 | |
| 12 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.