Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter Scan Bluetooth returning paired devices not the connected devices #1

Open
msrikanthkan opened this issue Oct 24, 2019 · 0 comments

Comments

@msrikanthkan
Copy link

I have a requirement where i need to identify the remote connected device, if any. As of now, with this package am only getting paired devices name and address.
I cloned this package into my visual studio code and tried to get the connected devices in Android by modifying the FlutterScanBluetoothPlugin.kt.

I added these lines in my code to get the connected devices, but somehow its not working.

`private var bluetoothManager: BluetoothManager? = (activity.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager)

private var adapter: BluetoothAdapter? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
this.bluetoothManager?.adapter
} else {
BluetoothAdapter.getDefaultAdapter()
}

var isConnected = this.bluetoothManager?.getConnectionState(device, BluetoothProfile.GATT)
println("device isConnected : " + isConnected)`

Please let me know if this is correct or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant