A JBoss Project
Red Hat

AeroGear News Artciles, posts, events, videos and updates.

AeroGear Android 2.1 has been released

by

We are pleased to announce the release of AeroGear Android 2.1. This release includes the Sync alpha libraries, Pipe and GCM fixes, and minor updates to our demos.

What’s New

Sync Alpha

AeroGear has released the first alpha of our data sync technology. This includes the AeroGear Sync Server and libraries for iOS, JavaScript, and of course Android. This technology allows for cross platform data synchronization as seen here :

AeroGear SyncDemo from Christos Vasilakis on Vimeo.

If you followed the development of the Android library you will remember that we originally tried to use Google’s XMPP services as the medium for data sync. Because of technical limitations we dropped this idea and moved to wrapping the Netty client provided with AeroGear Sync Server in an Android service instead.

To activate the service you need to add it to you AndroidManifest.xml file. You will also need to provide properties for serverHost, serverPort, and serverPath. These properties are defined by where you have deployed the sync server. Here is an example connecting to the sync server running on the host of an emulated Android device:

<service android:name="org.jboss.aerogear.android.sync.SyncService">
  <meta-data
  android:name="serverHost"
  android:value="10.0.2.2" />
  <meta-data
  android:name="serverPort"
  android:value="7777" />
  <meta-data
  android:name="serverPath"
  android:value="/sync" />
</service>

Any Activty you want to receive sync events needs to implement the SyncServerConnectionListener interface, bind itself to the SyncService instance, and then subscribe to events on connections.

Binding and subscribing example :

@Override
protected void onStart() {
 super.onStart();
 serviceConnection = new ServiceConnection() {
 
  @Override
  public void onServiceConnected(ComponentName name, IBinder service) {
   final SyncService syncService = ((SyncService.SyncServiceBinder) service).getService();
   SyncActivity.this.service = syncService;
   syncService.subscribe(SyncActivity.this);
  }
  
  @Override
  public void onServiceDisconnected(ComponentName name) {
   finish();
  }
 };
}

@Override
protected void onResume() {
 super.onResume();
 Intent syncServiceIntent = new Intent(this, SyncService.class);
 bindService(syncServiceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
}

SyncServerConnectionListener implementation Example :

@Override
//Called when the SyncService instance is connected to the Sync server AND the Activity is subscribe to the service after binding.
public void onConnected() {
 /*clientId is a unique identifier which identifies the device connection*/
 clientId = getSyncService().getClientId();
 
 /*a client document is a document the sync APIs know how to synchronize and is managed by the sync libraries*/ 
 final ClientDocument<JsonNode> clientDocument = clientDoc(documentId, clientId, JsonUtil.toJsonNode(content));
 
 /*adding a document to the service causes it to send and receive updates*/
 getSyncService().addDocument(clientDocument);
}

@Override
//Called when the document is updated by an external source
public void patched(final ClientDocument data) {
 runOnUiThread(new Runnable() {
  @Override
  public void run() {
   final ClientDocument<JsonNode> document = (ClientDocument<JsonNode>) data;
   final Info updates = JsonUtil.fromJsonNode(document.content());
   //handle your updates here.
  }
 });
}

For a full implementation demo look at our cookbook.

Minor Changes

Pipe improvements

After nearly two years we have implemented AGDROID-7 by adding Pipe.read(String id, Callback<T> callback). Now fetching by id is as simple as the following:


private void retrieveData() {
  LoaderPipe<Data> pipe = application.getPipe(this);
  pipe.reset();
  pipe.read(String.valueOf(15), new MyCallback());
}

GCM Push Configuration

We’ve added some extra validation to the GCM Push Registrar. Now if you leave off properties such as variantId the library will throw an exception when you try to build the PushRegistrar as opposed to the registration method failing with an error callback.

GCM Unregistration

Now the library will check to see if you have a registered client before it attempts unregistration. Previously it would always make a call to the Push Server which would fail with a HTTP 404 error if you were not registered. Now the method immediately fails without a network call.

Demo Improvements

We’ve added a few demos to the official cookbook.
* Sync Demo This is the demo for our sync libraries.
* Two Factor This is an example of a Two-Factor One Time Password app using AeroGear.
* Password Manager This demonstrates using encryption to secure a password store behind a passcode.

We’ve also fixed some bugs in the Shoot and Share app as well as the AGReddit app.

What’s Next

For 2.2 and the future we are looking at improvements to our authz libraries as well as better offline resource management. As per usual you can watch our JIRA

About AeroGear

If you would like to learn more about AeroGear’s Android libraries a great place to start is our Android landing page. If you would like to participate in development, have questions, or want to chat with us our community section has all of our contact information.

##Changelog

  • AGDROID-362 Migrate AeroDoc example to Gradle and move to cookbook repo
  • AGDROID-156 Update aerogear-crypto-android-demo and move to cookbook repo
  • AGDROID-343 AeroGearGCMPushConfiguration#buildRegistrar needs more validation
  • AGDROID-361 AGReddit should say Bad Password when you fail at logging in.
  • AGDROID-7 add pipe functionality to retrieve data by ID
  • AGDROID-312 Implement Android Client Sync Engine
  • AGDROID-369 Sync Android Demo app
  • AGDROID-313 Implement Android Sync Client
  • AGDROID-368 unregister fails with server returned the error code 405 android
  • AGDROID-385 Update AeroGear Sync README
  • AGDROID-377 Move DiffSync client into a android.app.Service
  • AGDROID-386 Deprecate and remove client-xmpp
  • AGDROID-370 XMPP Client NPE @ DiffSyncClientHandler.java:45
  • AGDROID-364 Package XMPP Sync Client to not include duplicate files
  • AGDROID-363 Refactor XMPP Sync Client to get below the 65k method limit
  • AGDROID-371 XMPP sync client should support json patch
  • AGDROID-367 Shoot-n-Share 401 error (invalid_client) on Google Drive upload
  • AGDROID-366 Shoot-n-Share does not offer keyboard for Keycloak redirected login screen
  • AGDROID-365 XMPP Sync Client does not handle multiple documents correctly

redhatlogo-wite