Best practices for AllJoyn use in mobile apps (Android/iOS)

asked 2015-04-30 02:34:36 -0700

chanetd gravatar image

We're figuring out how to best use AllJoyn in mobile applications that will run on Android and iOS devices. There are two issues that always come back for these applications, and I can't really find a good explanation for them in the AllJoyn documentation:

  • battery life: what is the impact of long-running AllJoyn-toting applications on the battery usage of your mobile phone? What are the best practices to minimize battery drain?
  • background operation: how can you best deal with AllJoyn when your application goes into the background?

Is there any documentation available for these topics today? A best practices document, perhaps? A well-engineered code sample to look at and learn from?

Let me dig into the two topics in a bit more detail below:

Battery Life The key aspect of reducing battery consumption for an AllJoyn application is no doubt keeping the network traffic to a minimum. What are the best ways to do this? I know you can reduce the frequency of pings (or even stop pinging) when your application goes into the background. Are there other useful methods for reducing network traffic? Should we turn off About discovery, for instance (i.e. call CancelWhoImplements)? Is there some kind of global switch you can flip in the BusAttachment to hibernate the AllJoyn part of your application when you want to reduce network traffic?

Background Operation I think the question here is different depending on the platform.

iOS: I know the options for background operation on iOS are fairly limited. Is it in any way possible to keep an AllJoyn connection open when your application moves to the background? Can you have bus objects that still respond to method calls while in the background, can you install signal handlers (sessionless or otherwise) that receive signals when you're backgrounded?

If that is not possible, how resilient is the AJNBusAttachment to backgrounding? I.e., my application goes to the background, and is revived 10 minutes later. Can I still use the AJNBusAttachment instance that I built before going into the background? Will my application, upon revival, still have the same unique name on the bus? etc.

Android: all of the above, but with the extra option of running AllJoyn in a service that does run in the background. One of the Android samples (I believe it's the chat sample) actually uses a foreground service to run the BusAttachment. That's pretty scary, as it causes icons to appear in the notification bar, which is pretty intrusive. What is the preferred approach for Android applications? Service? Foreground service? Shut down the BusAttachment when you move to the background?

edit retag flag offensive close merge delete

Comments

the core working group is looking for people to maintain iOS/OSX bindings, SDKs, and documentation, if you're interested in helping.

ry.jones ( 2015-06-18 11:54:21 -0700 )edit