简体   繁体   中英

Android Development: Discovery of other devices using my app over Bluetooth

I am developing an android app where users must be able to see other users nearby them and send a message to that user specifically. I was hoping Bluetooth would be a good, low-energy solution to this. My trouble is in identifying nearby Bluetooth devices only if they are using this app, and ignoring all others, such as portable speakers and whatnot. Could anybody maybe point me in the right direction on this one?

As far as limiting the discovery, this seems not possible at this point in time. The only way I can think of where this would really be possible is if their device name had a particular string in it that you used to filter, but this isn't really something I would look into as people probably won't go as far as changing the name of their device just for an app.

You can use the following to change the device name, I would recommend getting permission & maybe appending the device's previous name onto whatever string you want to look for

BluetoothAdapter mBtAdapter = BluetoothAdapter.getDefaultAdapter();
mBtAdapter.setName("");

I don't think if you are in the middle of a connection it would end it, as a bluetooth connection is made using the devices bluetooth MAC address, not the devices name

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