Creating Contextual App Experiences

Summit 2018

-Prabhanshu Attri

Agenda

  • Context? What's that?
  • Nearby Connections
  • Awareness API

Source: LiveMint

My Watchlist

Soap Opera: What Name Do I Give To This Love?

Notifications

Source: https://media.makeameme.org/created/what-if-i-dezgm5.jpg

URL

https://xprss.org/starwars

Nearby Connections

  • Nearby Connections is a peer-to-peer networking API that allows apps to easily discover, connect to, and exchange data with nearby devices in real-time, regardless of network connectivity.

Source: developers.google.com

Source: https://www.beaconsage.com/media/1742/nearby-notifications-android.jpg

Nearby Settings

Beacon Dashboard

Publish and Subscribe

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

Awareness API

Contexts

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?

Various Contexts

Ways to get Insight

Fetch API

Snapshot API

Fetch 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();

Snapshot API

Thank you

@PrabhanshuAttri

prabhanshu.com

@PrabhanshuAttri

Creating Contextual App Experiences

By Prabhanshu Attri

Creating Contextual App Experiences

User context and their interactions with the nearby world play a vital role in creating a magnificent user experience. Instant awareness of the nearby surroundings can be an amazing way to understand the users and their behaviors. The emerging new technologies like Google's Awareness and Nearby APIs, Beacons, NFC cards and WiFi signals have opened up a sea of possibilities for developing magical user experiences. This talk will encompass the importance of user context, Eddystone beacons, Google's Nearby and Awareness APIs; and examples of some of the experiences you can build with them. It will also cover ways to understand user behavior and customisation based on user actions eventually resulting in user retention.

  • 1,662