esc_pos_bluetooth icon indicating copy to clipboard operation
esc_pos_bluetooth copied to clipboard

Printer Scann not Working in Android 11

Open putera- opened this issue 3 years ago • 22 comments

Device list is empty in OPPO Reno 5. Run Android 11. No detect printer at all. Haven't try at other android 11 device yet.

But work well in my old Redmi note 3, with Android 6.

Please update

putera- avatar Apr 07 '21 01:04 putera-

Device list is empty in OPPO Reno 5. Run Android 11. No detect printer at all. Haven't try at other android 11 device yet.

But work well in my old Redmi note 3, with Android 6.

Please update

I face same problem i fix it by change compileSdkVersion & targetSdkVersion (android/app/build.gradle) from 30 to 28 and the devices list to me

IRizerX avatar May 04 '21 12:05 IRizerX

Hi, I was facing the same problem. It turns out that GPS location should be enabled in order to discover nearby devices. Enabling GPS worked for me.

In android documentation its mentioned that "Services running on Android 10 and higher cannot discover Bluetooth devices unless they have the ACCESS_BACKGROUND_LOCATION permission. For more information on this requirement, see Access location in the background.". Reference can be found here

tehsunnliu avatar May 10 '21 08:05 tehsunnliu

I face same problem. I have try in VIVO, Samsung android V.10 - V11

NongBritee avatar May 24 '21 16:05 NongBritee

Eu enfrento o mesmo problema. Eu tentei no VIVO, Samsung android V.10 - V11

even activating the GPS did not work?

renanzdm avatar Jun 02 '21 17:06 renanzdm

Same here, even with gps active.

carlosfred avatar Jun 13 '21 14:06 carlosfred

This plugin is showing many errors, I advise you to change

renanzdm avatar Jun 15 '21 14:06 renanzdm

Do you sugest one ?

carlosfred avatar Jun 15 '21 14:06 carlosfred

Hi I have same error but I fixed . A added below peermission Manifest.xml

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> 

then When I opened select printer page , I will check permission and then all printers will be shown. await Permission.locationAlways.request().isGranted;

printerManager.scanResults.listen((devices) async {
  // print('UI: Devices found ${devices.length}');
  setState(() {
    _devices = devices;
  });
});
_startScanDevices();

ozhankucuk avatar Jul 08 '21 17:07 ozhankucuk

I tried @tehsunnliu and @ozhankucuk both suggestions. But still not working in my phone. I have redmi note 9 with MIUI 12.0.1 and android 11. Build app with unsound null safety and app was of size 47mb!!! Please someone help guys. I have this printer and have to make it work.

harshilishere avatar Sep 07 '21 04:09 harshilishere

I've been working on a package, I don't know if it suits you but for me it worked but on Android you need to first pair with the printer and only then it will show in the list https://github.com/renanzdm/pos_printer_manager_forked

renanzdm avatar Sep 07 '21 11:09 renanzdm

@renanzdm hey thank you for the reply. Yes i have paired the device and its working fine in Rawbt app. But not showing in mine.

harshilishere avatar Sep 07 '21 13:09 harshilishere

using which package? what i sent or esc pos bluetooth

renanzdm avatar Sep 07 '21 16:09 renanzdm

@renanzdm thanks a lot to you man! your repo worked for me! Now I just need your help to print qr codes and usual normal texts instead of html. Thanks a lot!!

harshilishere avatar Sep 08 '21 02:09 harshilishere

with this project you will need to build everything using HTML from qrCode to plain text as it does an HTML conversion to a page and then prints it

renanzdm avatar Sep 08 '21 09:09 renanzdm

@renanzdm yeah i understood that. But can you guide me how to do it without html too? like normal text?

harshilishere avatar Sep 09 '21 01:09 harshilishere

I don't understand your question, as the package is transforming the html into an image you would have to transform the text into an image too

renanzdm avatar Sep 09 '21 12:09 renanzdm

My point is, I will have to write html in order to use your package. What if i want to do something simple than that? For this i have to write a code that would take inputs from the text field generate a html than convert it to image and than it will print.

harshilishere avatar Sep 10 '21 13:09 harshilishere

Yes always with html. because of text formatting and other things that just plain text wouldn't look good

renanzdm avatar Sep 10 '21 13:09 renanzdm

You can create methods and create an html for you and you just insert the text you want

renanzdm avatar Sep 10 '21 13:09 renanzdm

@renanzdm cool sounds like an alternative! thanks man!

harshilishere avatar Sep 12 '21 04:09 harshilishere

After tons of trial and errror, finally made it work on the example app with targetSdkVersion 30, based on clues given in this issue (location permission needed), thanks!

hope this will help:

android/app/build.gradle: image

android/app/src/main/AndroidManifest.xml image

main.dart: image

howmun avatar Mar 30 '22 12:03 howmun

@howmun Thank you very much :)

HassanShaban avatar Jun 19 '23 12:06 HassanShaban