简体   繁体   中英

How to scan for another device through Bluetooth- Xamarin

I'm developing Xamarin application using Visual Studio 2019. I have to connect to another device through Bluetooth and send some data and receive acknowledgement back. Tried these two samples out

  1. https://github.com/msthrax/BLEApp

    and

  2. https://github.com/didourebai/BLEPluginDemo .

But didn't help me while scanning for nearby Bluetooth devices , since the below codes are not giving expected result respectively..

1.

listView_DeviceList.ItemsSource = CrossBluetooth.Adaptor.GetListOfDiscoveredDevices();

and

2.

adapter.DeviceDiscovered += (s, a) =>
{
    deviceList.Add(a.Device);
};

Both Bluetooth and location turned on in my devices. Can anyone let me know the possibilities of problem here. I don't have any build errors in both of the above samples. Whereas, I have one surprise also. Below line is giving proper result, which is of no use for me currently.

listView_PairedDeviceList.ItemsSource = CrossBluetooth.Adaptor.GetPairedDevices();

After enabling the Location Permission for the app(earlier, I turned on Device Location, but we should allow the app to get device location ), all my above problems are solved out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM