question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android 13 Scan issue

See original GitHub issue

After install Android 13, SDK 33, There is no results in DeveceDiscovered.

I`m sure device is available for scaning and it near me. I can see it from phone bluetooth settings/ Device is ble. Bluetooth is On and permissions are done in manifest and runtime. Bluetooth.Scan/advertize/admin/previleged/connect.Location permissions, nearby devices/hardware.bluetooth_le etc.

Anybody implement it on Android 13? Where can be a problem

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
88soulscommented, Mar 16, 2023
  1. Manifest: android:minSdkVersion=“28” android:targetSdkVersion=“33” android.permission.ACCESS_NETWORK_STATE" android.permission.INTERNET" android.permission.BLUETOOTH" android:maxSdkVersion=“30” android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion=“30” android.permission.BLUETOOTH_PRIVILEGED" android.permission.BLUETOOTH_CONNECT" android.permission.BLUETOOTH_ADVERTISE" android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags=“neverForLocation” android.permission.ACCESS_COARSE_LOCATION" android.permission.ACCESS_FINE_LOCATION" uses-feature android:name=“android.hardware.bluetooth” android:required=“true” uses-feature android:name=“android.hardware.bluetooth_le” android:required=“true” uses-feature android:name=“android.software.companion_device_setup” uses-feature android:name=“android.hardware.location” android:required=“false”
0reactions
88soulscommented, Mar 16, 2023

So i fix this in my code, here is some things i did:

  1. Manifest: <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-feature android:name="android.hardware.bluetooth" android:required="true" /> <uses-feature android:name="android.hardware.bluetooth_le" android:required="true" /> <uses-feature android:name="android.software.companion_device_setup" /> <uses-feature android:name="android.hardware.location" android:required="false" />

  2. Additionaly there is permission called in phone “NEARBY DEVICES”. You should ask user in runtime from ANDROID project, I ask from additional service. Permissions namespace Xamarin.Essensials (From core I use Plugin.Permissions and its ok):

public async Task<PermissionStatus> CheckAndRequestBluetoothPermissions() { PermissionStatus status; if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.S) { status = await Permissions.CheckStatusAsync<BluetoothSPermission>();

            if (status == PermissionStatus.Granted)
                return status;
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this._activity);
            alertDialogBuilder.SetTitle(Localization["Permission required"]);
            
            alertDialogBuilder.SetIcon(Resource.Drawable.ic_alert);
            alertDialogBuilder.SetMessage(Localization["BluetoothPermissions"]);
            alertDialogBuilder.SetCancelable(false);
            alertDialogBuilder.SetPositiveButton(Localization["Ok"], async (senderAlert, args) =>
            {
                status = await Permissions.RequestAsync<BluetoothSPermission>();
                alertDialogBuilder.Dispose();
            });
            alertDialogBuilder.SetNegativeButton(Localization["Cancel"], async (senderAlert, args) =>
            {
                alertDialogBuilder.Dispose();
            });

            Dialog diag = alertDialogBuilder.Create();
            
            diag.Show();
            
        }
        else
        {
            status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();

            if (status == PermissionStatus.Granted)
                return status;

            InvokeOnMainThread(() =>
            {
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this._activity);
                alertDialogBuilder.SetTitle(Localization["Permission required"]);
                alertDialogBuilder.SetIcon(Resource.Drawable.ic_alert);
                alertDialogBuilder.SetMessage(Localization["LocationWhenInUse"]);
                alertDialogBuilder.SetCancelable(false);
                alertDialogBuilder.SetPositiveButton(Localization["Ok"], async (senderAlert, args) =>
                {
                    status = await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
                    alertDialogBuilder.Dispose();
                });
                alertDialogBuilder.SetNegativeButton(Localization["Cancel"], async (senderAlert, args) =>
                {
                    alertDialogBuilder.Dispose();
                });
                Dialog diag = alertDialogBuilder.Create();
                diag.Show();
            });
        }
        return status;

After all this things, it starts work. Note if you dont have exeptions, but DeviceDiscovered() and DeviceAdvertised() not starts, its permissions issue. I hope you will be OK with this

Read more comments on GitHub >

github_iconTop Results From Across the Web

PSA: If you updated to Android 13 and can't use the "Scan ...
PSA: If you updated to Android 13 and can't use the "Scan QRCode" quick-settings tile due to it being "unavailable", update your camera...
Read more >
Issue with Scan Storage setting in Android 13 - Discussions
Hello, I'm using Intercept X for Mobile on a Nokia C32 running Android 13 and I could no longer turn on the Scan...
Read more >
Re:Scan QR Code not working on Android 13.
In Android 13, we have a new feature which is scan QR code tile option. However, it is not working on my device....
Read more >
Quick Settings QR code scanner bottom is disabled after ...
A week ago I update my pixel 5 to the new android 13 and after that I'm unable to use the new qr...
Read more >
6 Best Ways to Fix QR Code Scanner Not Working on ...
6 Best Ways to Fix QR Code Scanner Not Working on Android · 1. Clean Your Camera Lens · 2. Check the Lighting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found