esc_pos_bluetooth icon indicating copy to clipboard operation
esc_pos_bluetooth copied to clipboard

android bluetotth scaning not working,ios working

Open iyashiyas opened this issue 2 years ago • 6 comments

Android Not scanning, ios working, is there. any option to scan paired devices ?

iyashiyas avatar May 20 '22 11:05 iyashiyas

Same issue, any solutions ??

ferns-it avatar Jun 08 '22 06:06 ferns-it

solved the issue with adding permission from flutter also added android manifest.xml

var statusLocation = Permission.location; var statusScan = Permission.bluetoothScan; var statusConnect = Permission.bluetoothConnect; if (Platform.isAndroid) { if (await statusLocation.isDenied) { await [ Permission.location, ].request(); }

    if (await statusLocation.isGranted &&
      await statusScan.isGranted &&
      await statusScan.isGranted) {
    commonPrint('all grnted');
    // do scan bluetooth device function
  }

iyashiyas avatar Jun 21 '22 05:06 iyashiyas

@iyashiyas @ferns-it can you share your AndroidManifest and a more detailed code snippet? Specifically have you used permission_handler package?

jobypthomas avatar Sep 14 '22 20:09 jobypthomas

@iyashiyas @ferns-it I was able to figure out. Thank you. However, it does not work with Android 12. Worked fine with Android 9.

jobypthomas avatar Sep 14 '22 21:09 jobypthomas

Android 12 doesn't work initially. You'll have to follow this: https://stackoverflow.com/questions/70578601/android-12-ble-scan-does-not-find-any-devices

As a result, I had these in the Android manifest file:

  <uses-permission android:name="android.permission.BLUETOOTH" />
  <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
  <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Then I request the following permissions at runtime:

await Permission.bluetoothConnect.request();
await Permission.bluetoothScan.request();
await Permission.locationWhenInUse.request();

eliezedeck avatar Sep 16 '22 19:09 eliezedeck

Thanks ,this works for me I migrated my project to null safety. targeting sdk 30 to 31

ozhankucuk avatar Sep 26 '22 14:09 ozhankucuk