The Android Linccer binding provides a UI thread aware variant of the Java API to communicate with the RESTful Linccer Services:
AsyncLinccer linccer = new AsyncLinccer(new ClientDescription("Demo Android App"));
// publish a gps position obtained from Android's LocationListener linccer.onGpsChanged(location);
// publish a wifi data obtained from Android's WifiManager wifiManager = (WifiManager) pContext.getSystemService(Context.WIFI_SERVICE); linccer.onWifiScanResults(wifiManager.getScanResults());
// creating and Android event handler to give user feedback Handler handler = new Handler() { @Override public void handleMessage(Message msg) { String toast = "transfer failed"; if (msg.what == AsyncLinccer.MessageType.SHARED) toastMessage = "sharing faild"; else if (msg.what == AsyncLinccer.MessageType.RECEIVED) toastMessage = "received " + (JSONObject) msg.obj;
Toast.makeText(this, toastMessage, Toast.LENGTH_LONG).show(); } };
// safely pass data to an other client here and now linccer.asyncShare("one-to-one", new JSONObject("{ 'demo' : 'arbitrary json' }"), handler);
// safely receive passed data from an other client here and now linccer.asyncReceive("one-to-one", handler);
More examples can be found at github.com/hoccer/android-demos.
- get the Android API source code with
git clone git
@github.com:hoccer/android-api.git
- fetch the Java API submodule with
git submodule --init update
- make sure you have the latest ADT Eclipse plugin. Previous versions had problems with library projects containing a dash in the project name
- start your new Android Project and add Android API source project as am Android Library Project (as described in http://developer.android.com/guide/developing/projects/projects-eclipse.html “Referencing a library project”)
- obtain your own API Key from developer.hoccer.com
- use a ClientConfig constructor apiKey and sharedSecret parameters
- change service base from sandbox.hoccer.com to hoccer.com
Also have a look at the Linccer Java-API which is included as a GIT submodule in this project. If you want to “git clone” this code directly from GitHub, remember to update the submodule with
git submodule update --init
This code is dual licensed (commercial and GPL v3). See LICENSE file for more informations about the GPL. Alternative licensing without the obligations of the GPL is available upon request.
Please check the general Linccer documentation.