title: SyncAdapter to receive chat messages?
body: <p>For my chat app I am looking for a good way to sync messages while the app is in background.</p>
  <p>At the moment I have a websocket. When the app comes to foreground, messages get synced. This makes the app looking laggy. Like WhatsApp I need a way to have all messaged synchronized before the app gets in foreground.</p>
  <p>I thought about the following solution:
  I set up a SyncAdapter which gets triggerd by a push notification (&quot;new message for chat xy&quot;). Then inside the SyncAdapter I fetch new messages.</p>
  <p>Now the problem is I do not want to connect (e.g. via REST) for each line which has been written. And also I don't want to wait x minutes to bundle new messages.</p>
  <p>As I said before, I already have a websocket which gets established when the app goes to foreground. Is it a good idea to move this code to the SyncAadapter? Can I keep the connection open there or should I close it if I dont receive a message for x minutes? The only problem I see is, if an user is not able to receive push messages.</p>
  <p>If anyone knows of famous chat apps do it, please point me to this direction.</p>