Summit 2018
-Prabhanshu Attri
Source: LiveMint
Soap Opera: What Name Do I Give To This Love?
Source: https://media.makeameme.org/created/what-if-i-dezgm5.jpg
https://xprss.org/starwars
Source: developers.google.com
Source: https://www.beaconsage.com/media/1742/nearby-notifications-android.jpg
Nearby.getMessagesClient(this).publish(new Message("Hello World".getBytes()));
MessageListener mMessageListener = new MessageListener() {
@Override
public void onFound(Message message) {
Log.d(TAG, "Found message: " + new String(message.getContent()));
}
@Override
public void onLost(Message message) {
Log.d(TAG, "Lost sight of message: " + new String(message.getContent()));
}
}
Nearby.getMessagesClient(this).subscribe(mMessageListener);
https://xprss.org/fossasia18wt
Context type | Example |
---|---|
Time | Current local time |
Location | Latitude and longitude |
Place | Place, including place type |
Activity | Detected user activity (walking, running, biking) |
Beacons | Nearby beacons matching the specified namespace |
Headphones | Are headphones plugged in? |
Fetch API
Snapshot API
AwarenessFence walkingFence
= DetectedActivityFence.during(DetectedActivityFence.WALKING);
AwarenessFence headphoneFence
= HeadphoneFence.during(HeadphoneState.PLUGGED_IN);
AwarenessFence walkingWithHeadphones = AwarenessFence.and(
walkingFence,
headphoneFence
);
AwarenessFence areaAroundStore = LocationFence.in(
STORE_LAT,
STORE_LONG,
1000, /* radius in meters */
0L /* dwell time */
);
AwarenessFence openHours = TimeFence.inDailyInterval(
TimeZone.getDefault(),
10 * HOURS_IN_MILLIS, /* 10AM */
18 * HOURS_IN_MILLIS /* 6PM */
);
AwarenessFence walkingWithHeadphonesNearStore
= AwarenessFence.and(
walkingWithHeadphones,
areaAroundStore,
openHours
);
// Update fence
FenceUpdateRequest fenceUpdateRequest
= new FenceUpdateRequest.Builder()
.addFence("walkingWithHeadphones", walkingWithHeadphones, mPendingIntent)
.addFence("walkingWithHeadphonesNearStore", walkingWithHeadphonesNearStore, mPendingIntent)
.build());
Awareness.FenceApi.updateFences(googleApiClient, fenceUpdateRequest);
PlaceResult placesResult =
Awareness.SnapshotApi.getPlaces(googleApiClient).await();
WeatherResult weatherResult =
Awareness.SnapshotApi.getWeather(googleApiClient).await();
Thank you
@PrabhanshuAttri
prabhanshu.com
@PrabhanshuAttri