GithubHelp home page GithubHelp logo

vicinity's Introduction

Vicinity Android SDK

by: Matthew Patience

  • You have 2 options when deciding how to build your application. You may either choose to build 2 separate applications, one for the remote and one for the server, or you can build 1 for both. The following describes 2 separate applications.
  • For the SDK to work properly both devices must be on the same local network since a direct IP connection is made and no firewalls can be allowed to block the connection.
  • This SDK supports Android 2.1+

Server Application Setup

  1. Start a new project and open up your AndroidManifest.xml. Insert the following permissions:
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
  1. Create a new class in your root package called "MyApplication" that extends VicinityApplication. If you have anything specific for your application to do here, then do so, otherwise you can leave it as an empty class.
  2. In your AndroidManifest add:
android:name=".MyApplication"

to your application tag. 4. Create an Activity and extend ServerActivity. Implement all the methods that are required to compile the class, these include connected(), disconnected(), messageReceived(), and connecting(). In this activity you will have to display an ImageView for the next step. Where you choose to put it is up to you. 5. On your ImageView from the last step call ImageView.setImageBitmap(Vicinity.getIpQrCode()) in your activity's onCreate() method. You can resize this bitmap before applying it the image if you wish. 6. Immediately after setting the QR Code image, call getServerManager().startListening(). getServerManager() is a method from the ServerActivity that you extended. 7. Ensure that you call stopListening() on the ServerManager after you are finished connecting devices. This could be done in onDestroy() for example. 8. Please note that the methods connected(), disconnected(), and messageReceived() will be called off the UI Thread. If you plan to modify UI during these methods you can post your changes to the UI Thread via View.post(Runnable).

Remote Application Setup

  1. Complete steps 1 - 3 of the server application setup for a new application.
  2. Create an Activity and extend RemoteActivity. Implement all the methods that are required to compile the class, these include connected(), disconnected(), messageReceived(), and connecting().
  3. You may make this UI interaction however you like but you will essentially require a way for users to start the scanning process. For example, in onClick() for a button you will need to call Vicinity.scan(Activity).
  4. When the users returns from the scanning process the connection to the server will automatically be made. When the device successfuly connects the connected() method will be called.

Interaction Options

From both applications simply call getServerManager() or getRemoteManager() and call sendMessage(), sendBroadcast(), or sendDirectMessage() to send messages.

vicinity's People

Contributors

matthewpatience avatar

Stargazers

Rodrigo avatar Jamie Evans avatar  avatar Ed Holloway-George avatar Wade avatar Dimitar Manolov avatar Rostislav Shnaper avatar Steve Liedtke avatar Chris Lacy avatar  avatar Soul_Est avatar  avatar Paul Burke avatar Brandon Broschinsky avatar Nick Presta avatar

Watchers

Lance Nanek avatar James Cloos avatar Raymond Kao avatar

Forkers

morristech bigsfr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.