esc_pos_bluetooth
esc_pos_bluetooth copied to clipboard
Error in scanning
Hi, i faced this error when the app start scanning.
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(startScan, Need android.permission.BLUETOOTH_SCAN permission for AttributionSource { uid = 10479, packageName = com.example.test_app, attributionTag = null, token = android.os.BinderProxy@899cb68, next = null }: GattService registerScanner, null, null)
i dont know whats the solution, please help me. thanks
goto your project -> android -> app -> src -> package name -> AndroidManifest.xml and paste the below code before
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
Try checking for permission
void initBTprinter() async {
await Permission.bluetoothScan.isDenied.then((value) {
if (value) {
Permission.bluetoothScan.request();
printerManager.startScan(Duration(seconds: 2));
}
});
}