Best practice for persistent mobile connectivity on Android?

I am considering using a permanent connection to a cloud service from an Android application. This will work all the time in the background (or something like that).

I am considering using network sockets or XMPP to maintain a connection, basically looking for a light connection that will not drain the battery. I want to be able to click real-time notifications on this connection, so periodic polling is undesirable. I know about C2DM and other commercial solutions, but I want to give up my own. This is why I use a web socket (or other lightweight connection). So, if I go along this route, which of the best practices should I know?

I think of things like:

  • how to prevent battery drain,
  • How to handle IP address changes, etc.
+5
source share
2 answers

This may not be the answer you are looking for, but I think you will want to rethink your architecture.

Things you can expect from a mobile platform

  • Your IP address for accidental change
  • Your physical Internet connection will be lost at random.
  • The OS will decide that you are not doing anything and are not killing your process.
  • The type of connection changes randomly (from WIFI to 4G to 3G to the edge) and thus your IP address to change

Basically, your application should be able to cope with the loss of communication, because it is almost guaranteed.

, , . , , . , .

+10

. "push- " " ". .

Android, XMPP, , , IP- . , . Yaxim, Project MAXS Beem, . , XEP-0286: XMPP

, , , Google C2DM? . , , " ". , , , - (~ 0-30 ).

+1

All Articles