Fetching messages from a server

by Kevin Anthony » Sun, 27 Mar 2011 00:25:00 GMT

Sponsored Links
 I have an application that needs to fetch messages from a server,
currently i do this via a service, running in the background.
However, when my application is not in the foreground, it quickly gets
pushed out of memory, and stops checking for messages.

I've been playing with AbstractThreadedSyncAdapter, but this seems a
little heavy handed.

Is there some middle ground?  Something i should look into?

Kevin Anthony


Re: Fetching messages from a server

by Mark Murphy » Sun, 27 Mar 2011 00:32:53 GMT

 On Sat, Mar 26, 2011 at 12:24 PM, Kevin Anthony

This is a good thing. An everlasting service like this is an
anti-pattern and should be avoided wherever possible.

little heavy handed.

Could be -- I haven't had a chance to mess with that yet.

Use AlarmManager and fetch the messages on a periodic basis, with the
user controlling the polling frequency (including an option for
manual-refresh-only) via a SharedPreference.

Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android Training in London:  http://bit.ly/smand1 ,  http://bit.ly/smand2 


Sponsored Links

Re: Fetching messages from a server

by Kevin Anthony » Mon, 28 Mar 2011 06:40:50 GMT

 Thanks, that did the trick

Kevin Anthony


Other Threads

1. Android on 7" device. What display resolution and which keys are needed?

>> Is this sufficien to get access to the Android market and to run 3.0 in
the future?
spec wise -> u just described lcd panel. android3.0 will have other
mandatory basic h/w requirements for processor Mhz, memory,
graphics,peripherals etc.
customer appeal wise -> even blackberry playbook about to come with 7"
panel., but with more pixel density.

IMO, WVGA on 7" will have low pixel density, will be less appealing. go for
bit higher resolution.

on the touchscreen
power button atleast? and how about couple of global OK,CANCEL keys?

> website: 

2. New Line in SMS

Hi all,

i'm trying to send 2 line of sms with this code

String messageToSent = "Some line\nAnother line";

SmsManager sms = SmsManager.getDefault();
                System.out.println("Sending SMS to: " + phoneNumber + ", 
message: "
                                + messageToSent);
                sms.sendTextMessage(number.getPhoneNumber(), null, 

but the the new line is not exist.. could anyone please tell me how to
insert new line (carriage return) in sms ?


3. Android on 7" device. What display resolution and which keys are needed?

4. webview cookie issue

5. help: kalo injek smart EVDOnya ngak mau up kenapa ya

6. How to fly to a location in Google Earth from your android app

7. Thread Local Storage and GDB server