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.

Unable to Find BLuetooth Devices after Scanning

See original GitHub issue

Can’t see any device during Scanning… I tried with Android Emulator 13 and also installed app on phone (Samsung) but was not successful on .net 6 MAUI

I am using API version 2.3.1

public partial class DeviceScanner
{
[Inject]
public BluetoothService BluetoothService { get; set; }

private Status workflow;
public string workflowText;

private HashSet<DeviceNode> devices = new();
private DeviceNode selectedDevice = null;
private SemaphoreSlim semaphoreSlim = new(1, 1);


private async void OnSearch()
{
    await semaphoreSlim.WaitAsync();
    try
    {
        devices.Clear();
        selectedDevice = null;

        SetWorkflow("Scanning for Devices...", Status.Lock);
        await Task.Delay(1500);

        devices = await BluetoothService.CrossBluetooth.StartDiscoveryAsync(Callback);

        if (devices.Count == 0)
        {
            await Toaster.ShowAsync("Unable to find nearby Bluetooth LE devices. Try again.");
        }
    }
    finally
    {
        var successText = "Scan completed. Select a device and Connect";
        var failureText = "Unable to find nearby Bluetooth LE devices. Try again.";
        var text = devices.Count > 0 ? successText : failureText;
        UnlockWorkflow(text);
    }

}

standalone git repository* Repo

Expected behavior

I expected to recieve visible BLE devices after Scanning

Actual behavior

After calling “devices = await BluetoothService.CrossBluetooth.StartDiscoveryAsync(Callback);” i do not recieve any device , no Bluetooth Device could be seen.

Configuration

<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />

**Version of the Plugin . 2.3.1

**Platform: Android Emulator 13 >

Device: e.g. HTC Sensation /i Phone 7 …

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bonifacebasseycommented, Apr 30, 2023

Yes i also requested permission at runtime.

Well, then you’re most probably doing something wrong somewhere. Hard to tell without a code sample for reproduction (or a working crystal ball) …

I will try it out again in some days and share a Repo to the source code if it doesn’t work

0reactions
januswcommented, Jul 3, 2023

@volcano619 could you find a solution?

Sounds like his problem was solved by this:

had to add Manifest.Permission.AccessCoarseLocation, Manifest.Permission.AccessFineLocation in the runtime permissions

I’m closing this issue. As soon as you do it right, it suddenly starts working 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

My Android Won't Connect To Bluetooth. Here's The Fix!
Put Your Bluetooth Device In Pairing Mode [1:30] 6. ... When you pair a Bluetooth device to your Android for the first time, ......
Read more >
Fix Bluetooth problems on Android
Can't pair with other accessories · Open your phone's Settings app. · Tap Connected devices. If you see "Bluetooth," tap it. · Tap...
Read more >
How to Fix Bluetooth Pairing Problems
1. Make sure Bluetooth is turned on · 2. Determine which pairing process your device employs · 3. Turn on discoverable mode ·...
Read more >
12 Quick Ways to Fix Bluetooth Problems on Android Devices
1. Try to Connect With a Different Device · 2. Turn Off Bluetooth and Then Turn It On Again · 3. Unpair the...
Read more >
How to Fix Bluetooth Pairing Problems - Techlicious
1. Make sure Bluetooth is turned on · 2. Determine which pairing process your device employs · 3. Turn on discoverable mode ·...
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