Detect nearby bluetoooth enabled devices running my app - android

When I researched about this problem I came across this. So I know this is possible in Wifip2p api, but I want to achieve the same thing with Bluetooth api. Is it possible?
In Wifip2p api the app broadcasts some text (let's say the app unique code) that other devices (running the same app) are listening and respond, so I can show the device list running my app. But is it possible to broadcast something to all nearby devices using the bluetooth api?

Of course it's possible. Bluetooth applications follow a typical client/server architecture. See the official Android documentation for more info.

Related

Transfer Data Using BLE with same application with in different android device

I need to transfer data from android phone to each other through my application using BLE. When a device comes near to me and my application is already installed in it, So my phone will establish a connection and send some data in strings and also receive from that device without notify user. Is it possible to do with BLE and I have studied BLE from
https://developer.android.com/guide/topics/connectivity/bluetooth-le
But I am new so I dont know from where to start and what should i have to do? Kindly let me know about BLE more easy for my better understanding and refer me some tutorials where I can learn that how will fulfill my application functionalities.
Thanks
I suggest starting with the Central-Peripheral example. Here you have an simple application:
https://github.com/itanbp/android-ble-peripheral-central
And tutorial with basis:
https://www.bignerdranch.com/blog/bluetooth-low-energy-on-android-part-1/
In the case you described, if there are not defined roles for the android phones (master, slave), the program will have to work in alternately in two modes: central and peripheral.
This is possible form the BLE side. However, there may be a problem with the application wroking as a background service. Since Android 8 there are new restrictions and limitations in background sericves:
https://developer.android.com/about/versions/oreo/background
Bluetooth Low Energy on Adnroid is very troublesome technology. A lot depends on the version of Android, processor and antenna system of the phone.

How to talk to a BLE device using Android phone?

I'm developing an app to communicate with a BLE device (Sensor puck from Silicon labs) and get whatever it is broadcasting.
I have NO experience in developing any sort of Bluetooth application using Android.
Do I need to manually pair it to the BLE device? I downloaded Sensor puck app from Play store, it automatically started to read from the device. I don't understand how since I didn't pair it.
Do I need specific API to communicate with the device? Is it like, I connect to the device and unpack the data which the device is broadcasting?
Any other information related to BLE application development would help.
Thank you.
PS: I can't use the app from the play store as I need the data from the device for some other processing.
I have a little experience with developing BLE apps.
Do I need to manually pair it to the BLE device?
I haven't encountered use case where I needed to pair mobile device with BLE device. Basically, you can communicate with BLE devices without pairing with them. BLE devices constantly emit signals and you can read these signals. Usually, from the emitted signals, you can read name of the device (or producer name), MAC address, RSSI signal from which you can compute distance from your mobile device to BLE device. Some BLE devices emit other information like temperature read from their sensors, etc. You can read information from more than one BLE device during the single scan.
Do I need specific API to communicate with the device?
Google provides API, which you can use to communicate with BLE devices. You can read more about it at: http://developer.android.com/guide/topics/connectivity/bluetooth-le.html. You can also use some third-party libraries allowing to communicate with BLE devices. Most of them are dedicated to so called Beacons, which are simple, tiny BLE devices.
Exemplary APIs for BLE Beacons:
Estimote
Kontakt.io
AltBeacon
ReactiveBeacons - this is open-source project, which I'm currently developing, so if you have any questions regarding it, you can ask me directly
Other projects:
Android Bluetooth Demo - this is very good and simple project, which can help you to understand how to use BLE API provided in Android SDK
Other information:
To communicate with BLE devices, of course, you need to have Bluetooth enabled on your device, but regardless of this permission, you also need to have Location enabled on your device and added location permission to your app. I guess it's done due to the fact, that you can use BLE devices for creating micro-location services.
I gathered some references concerning BLE for myself. You can check them here: https://github.com/pwittchen/ReactiveBeacons#references and maybe they will be useful for you as well.
Regards,
Piotr
it might be too late, but it also might be helpful for other users. So Sensor Puck works like a simple beacon and it doesn't require any pairing. You just have to scan all bluetooth devices nerby and verify received ScanRecord object. You don't have to use any specific libs or API, Anroid sdk contain all necessary api for such case (please see BluetoothAdapter startScan, startLeScan, etc). Also you can find an example how to parse raw data in my demo project https://github.com/alexeyosminin/sensor_puck_demo

Android discovering same app UUID devices

I am using bluetooth adapter to discover bluetooth devices. The search displays all devices (iOS , Android, Speakers etc) which are available in surrounding with Bluetooth turned ON.
My App sends and receive data, so installed on two different Android Devices, app can perform a chat functionality, provided both apps are using same App UUID.
Is it possible that when I perform the device discovery/search, I only limit discovery to those devices which are Android and are using my App i.e. my App UUID and not to show all other bluetooth devices.
I know this happens in iOS using characteristic UUID.
Appreciate Response.
1) First you're doing an Inquiry (search) of all nearby devices
2) for each device enumerated, do a Discovery (SDP) on it to gather all its services/profiles; If you found the one you're searchnign for, display it, otherwise forget it...
PS: I have no idea about selecting Android devices only... You can use the CoD (Class Of Device) but not sure that you can separate Android from other "smartphones"...

Android app that alerts other android devices nearby

So I am trying to develop an idea that has two core apps -
The user
The "alerter"
Basically, the alerter sends out a message that is received by all the phones with the app made for the users, but within a specific radius and not all. Any old programs I can look up into? or any tips, ideas? I'm literally new to the android coding world.
Your help is highly appreciated. Thanks :)
There are numerous ways that could be done, including:
Bluetooth detection
this is not feasible until Android supports becoming a Bluetooth Low Energy transmitter
WiFi detection
the devices must be on same access point to have network connectivity with each other
Server-side
All devices update a common server with their location
Devices can then query server for (reported) nearby devices
Server can also push new devices using GCM or Push IO
You could maybe start by looking for apps that do this sort of thing already. One is the instant-messaging app WeChat, and there are also some dating apps that allow users to make contact with nearby potentials.
Also read Find nearby users of an app (iPhone and Android)
I think you should start with Google Cloud Messaging:
Google Cloud Messaging for Android (GCM) is a service that allows you
to send data from your server to your users' Android-powered device,
and also to receive messages from devices on the same connection. The
GCM service handles all aspects of queueing of messages and delivery
to the target Android application running on the target device. GCM is
completely free no matter how big your messaging needs are, and there
are no quotas.

Android Proximity Messaging

Is it possible in the Android API to communicate directly to another android phone within close proximity? If so, which version of the API is it in? For example, if both phones had the same app, can they exchange messages in the background within close proximity?
The short answer is yes. Some apps, i.e. Bump, already do that. Usually android phones have both WiFi and Bluetooth capabilities. Given that you are talking about close proximity Bluetooth should be enough for you. Alternatively once one of them is configured as a WiFi hotspot, you can connect them via WiFi.

Categories

Resources