Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Nearby

Introduction to Nearby

Introduction, examples and code about the new Nearby Messages API from Google.

Presented at Android Talks #1, Coimbra, Portugal.

Sérgio Santos

October 21, 2015
Tweet

More Decks by Sérgio Santos

Other Decks in Programming

Transcript

  1. Main features • Works on Android, iOS and beacons •

    Apps can publish/subscribe to messages • Up until 100 meters range, or just earshot
  2. Limitations • Needs Internet! • Small messages (recommended 3KB or

    less) • Not for sensitive data • Only between the same apps • Not on the background (consumes a lot of battery)
  3. Internal flow 1. Publisher sends a Message to Google and

    gets a token 2. Subscriber just asks Google for a token 3. Publisher & Subscriber broadcast tokens (using techs) 4. When they “hear” other tokens, they let Google know 5. Google delivers the message to the Subscriber
  4. Let your imagination fly - Streetpass Over 50 games •

    Sharing scores • Unlocking content • Exchange items • ...
  5. Publish // Publish bytes to send String helloWorld = "Hello

    World!"; mMessage = new Message(helloWorld.getBytes()); Nearby.Messages.publish(mGoogleApiClient, mMessage);
  6. Subscribe mMessageListener = new MessageListener() { @Override public void onFound(Message

    message) { Log.i(TAG, "Found message: " + message); } @Override public void onLost(Message message) { super.onLost(message); Log.i(TAG, "Lost message: " + message); } };
  7. Best Practices • Battery! • Wait for user actions •

    Show users what is going on • Well defined stop
  8. Resources • Google Developers • https://developers.google.com/nearby/ • Nearby Messages (100

    days of Google Dev) • https://www.youtube.com/watch?v=hultDpBS22s • Getting Close With Android Nearby • http://fragmentedpodcast.com/episodes/17/