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?

-- 
Thanks
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







-- 
Thanks
Kevin Anthony
www.NoSideRacing.com

-- 



Other Threads

1. problem in installing ADT Plugin for Eclipse

Hello Developers

My Andriod is installed: C:\android-sdk-windows
Java is installed: C:\Sun\SDK\jdk
Eclipse is installed: C:\Program Files\eclipse

After successfully download 'ADT Plugin for Eclipse' in the Help-
Development Tools" as it gives me the following error:
----------------------------------------------------------------------------------------------------------------
java.lang.NoClassDefFoundError

Unexpected error encountered while preparing for the operation.
org/eclipse/ecf/filetransfer/BrowseFileTransferException
----------------------------------------------------------------------------------------------------------------
I'd be grateful if anyone could help me in this issue.

Thanks
Farhan

-- 

2. RelativeLayout bug ?

Hi all.

I suppose it's not a bug but a "works as designed" but I found this to
be really frustrating.
The use case is simplified just to the point that is a problem for me.

Here is the first layout that works :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
                <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Test"
                        android:gravity="center_vertical"
                />
</LinearLayout>


and the layout that doesn't works :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
                <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Test"
                        android:gravity="center_vertical"
                        android:layout_alignParentBottom="true"
                />
</RelativeLayout>

In the first case, "Test" is written to the top of the screen.
In the second case, "Test" is written in the miiddle of the screen.

It seems, for me, that LinearLayout perfoems correctly.
That's not the case for RelativeLayout.

Yes, if we remove "alignParentBottom" to the RelativeLayout case, it
works, but for what I wan't to do, I really need it.

So, does anybody knows if it is really a bug and maybe there is a
workaround or it is the expected behavior and eventually ... why ?

Thanks a lot !

Mike

-- 

3. Video window and OSD window in OMAP3530

4. Insert animation between video playback?

5. monitoring the http traffic

6. Iseng - Fake About Phone

7. Download a file from a URL extremely slow, am I doing it right?