Dynamically Changing BLE Advertisement Data Android - java

Is it possible to change the BLE Advertisement data while BLE advertisement is going on(with out having to stop and start the advertisement).
Use Case : Reading a value of sensor (Say Accelerometer sensor) and advertising it every 1 second.

Yes, you can do it with the setAdvertisingData method from the AdvertisingSet class. However this class was added in API 26 so for previous versions of Android, you will have to restart the advertising.

Related

Android Classic Bluetooth make UUID public

Seems like when made discoverable, an android device (A) doesn't show it's UUIDS, unless the device trying to get it's UUIDS (B) is paired with it.
Any body know how to make it's UUIDS public to any device ? By the way I'm not working with BLE, only Classic Bluetooth

How can I check that the received beacon is a beacon that last 2 minutes?

I have to make an android application with the purpose of a user check-in on a bus. The app have to research the beacons from a bus and at the same time has to send a beacon. How can I check that the received beacon is a beacon that last 2 minutes, in order to understand that the user is actually on the bus and he's not passing by?
As a starting point, I'm using https://github.com/Jaosrikate/iBeacon-Android and I'm trying to make some changes.
Do you have any suggestions on how to do this?
Beacon ranging involves a callback from the API that gives you a beacon identifier. The time of the callback is the time the beacon was detected.
The basic algorithm is simple:
Create a HashMap<String,Date> to store the timestamp of the first time a beacon was detected. Use a string representation of the beacon identifier as the key.
Whenever a beacon is detected, check to see if it’s identifier is already in the map.
If the identifier is not in the map, store it along with the current Date()
If the identifier is in the map, check to see if the current time - the stored time in the map > 2 minutes. If so, you have a match

Detect the detection order of beacons?

I have 2 beacons. Is there possible to see in what order my app have detected the beacons??
I’m trying to detect if someone is entering/exit in a space based on the order in which beacons are detected. If this is not possible, do you know how can I do that?
When using beacon monitoring APIs (e.g. you get a didEnterRegion callback), you typically don't know which beacon triggered the entry and whether a second beacon entered again. To get this information you need to use beacon ranging APIs.
When using beacon ranging APIs (e.g. you get a didRangeBeaconsInRegion callback), the callbacks will be made in a ~1 second frequency. If you record a timestamp the very first time you get a callback for a particular beacon and then associate it with the beacon identifier, you can later tell which which beacon identifier was detected first.
If two beacons appear simultaneously within the same callback, then you need a more accurate timestamp than you can get by just looking at the time the callback was made. If you are using the Android Beacon Library version 2.17+, you can get this kind of timestamp by calling beacon.getFirstCycleDetectionTimestamp(). That method returns the number of milliseconds since 1970 that the first beacon packet was detected that led to the ranging callback.

android wear : how to store data in WearableListenerService and access them?

I am a java/android beginner, trying to develop a simple wear app.
I am using a WearableListenerService to listen for data change from the handset and display these data on the wearable.
These data represent the user context, let's say the number of beers he has drunk in the past 5 minutes.
So, I have a int beerContext on the Handset and on the Watch that I'm trying to synchronize so that display on the watch and on the handset is the same.
As long as the number of beers is set from the handset only, everything is fine. Thanks to the data events gathered by the WearableListenerService.
BUT : I would like to make a little UI on the watch so that the user can update its number of beers drank.
My question is : the numberOfBeers is a private variable of the WearableListenerService. How can a watch activity update this variable as I didn't find any way to get a reference to the WearableListenerService? (I tried to override the onBind method, but it is final, so that's impossible.
I would very appreciate some precious advices as I might have done mistake in my app design.
A big thank!
I think you are misunderstanding how the data communication between the wear/phone works.
Each app will need to implement its own WearableListenerService, and each app will need to send data to the other app through the data api. Your private variable has no effect - theres no way to access this from the other app.
Have a read through Syncing Data items.
When sending the beer count from either the phone app or the wear app, you will need to send it with the data api:
e.g.
PutDataMapRequest dataMap = PutDataMapRequest.create("/beerCount");
dataMap.getDataMap().putInt(BEER_COUNT_KEY, beerCount);
PutDataRequest request = dataMap.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
.putDataItem(mGoogleApiClient, request);
You will then get notified in the WearableListenerService when that data is received.

Device Tokens are different from one device to another device

Hi i am little bit confusion about Device Token so can any one guide me. I am using following code for getting DeviceToken.
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)dt
{
}
The above code is working fine and it is showing DeviceToken data ,that is 64 length data.
My doubt is Device Token is different from one device to another device.
If once we got DeviceToken using one device that same DeviceToken can use for another Device.
Of course the device token is different for each device. It identifies a unique device. It's like a phone number (actually it's even more unique than a phone number, since multiple phones can have the same phone number). If it was the same, how would the Apple Push Notifications server know to which device to send your notification?

Categories

Resources