Hi Simon,

We've encountered the same problem while developing our app. We are
using the new startForeground method (and falling back on the old API
if the new one is not available; there is an example somewhere in the
docs of how to do that using reflection). This seems to keep our
process around even in low memory situations. Of course there can be
some extreme low memory situations when Android has no choice but
start killin the foreground services as well. We've noticed that when
the process does get killed, our notification stays at the top (I
know, it's weird and it happens even in froyo), so when our Service
restarts (it usually restarts in about 5 seconds if you start it with
the sticky flag) we make sure to cancel all notifications.

We've seen something almost as weird happen sometimes. If you start
your service using startForeground and then for some reason you cancel
your notification (we were doing this to show a new notification, with
numbering on top), then your process seems to be deemed less important
and will get killed a lot more often. I think it is not considered
foreground anymore if you cancel your notification after starting it.
We've had to release an update because we noticed this behavior after
we released it.

Maybe the Service and the Notifications api could use some
improvements. For one, I would like to be able to use the Notification
numbering even if it starts with 0, which is the normal case.



On Aug 12, 6:25 am, Simon Broenner <simonbroen...@gmail.com> wrote:
> Hello everyone!
>
> Aftera few months of living with the problem, I'd like to try to
> understand what's going on here. In the mean time, I've switched to
> the HTC Desire, and even though I constantly have 200MB+ of RAM free,
> IM apps are still crashing and burning in the background, with the
> exact same symptons (except for the low memory warnings - haven't
> spotted any of those on the Desire yet). Guess it's not just a lack of
> free memory?
>
> I have, in the mean time, discovered an app that manages to work
> around the problem by restarting itself each time it's closed: IM+
> 2.x. However, the developers seem to have removed this feature in
> their latest release, 3.0.11, which exhibits the same symptoms as all
> the other apps. The new Nimbuzz 2.x release also displays the same
> unfortunate behaviour.
>
> Is it really possible that the devs of _all_ these applications are
> doing something wrong? Is there no possibility that there is an error
> of some sort in the frameworks and APIs used for building background
> apps?
>
> How can I gather more information about this problem? I'd love to see
> it solved, as the only functioning messaging program (IM+ 2.x) has
> other problems of its own and lacks support for Skype.
>
> Thanks everyone!
>
> On Jun 24, 9:10 am, FrankG <frankgru...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > Hello Kostya,
>
> > can you please elaborate this a little bit :
>
> > a) For me it seems, that the Notifications from a service
> >       without the  foreground stuff are not deleted when you kill the
> > service
> >      ( i.e. using Settings-Applications-Running Services )
>
> > b) what did you mean with 2.x -API ?
>
> >     I use notify nd cancel normally.
>
> > Thanks a lot !
>
> >    Frank
>
> > On 23 Jun., 19:17, Kostya Vasilyev <kmans...@gmail.com> wrote:
>
> > > Simon,
>
> > > Android 2.x framework has an important change in this area, trying to
> > > nudge developers towards better behaving services.
>
> > > Since 2.x, marking a service as "foreground" requires a status bar
> > > notification, so the user knows that a service is running.
>
> > > Regarding lingering status bar notifications - I just verified that if a
> > > notification is displayed using the new 2.x API, it disappears when the
> > > service is killed.
>
> > > -- Kostya
>
> > > 23.06.2010 20:36, Simon Broenner пишет:
>
> > > > By the way: All the apps have already implemented the notifcation icon
> > > > in the status bar. The problem is, it doesn't change when the app is
> > > > killed in the background, so the user doesn't know that it's been
> > > > killed.
>
> > > > :(
>
> > > > Kostya Vasilyev wrote:
>
> > > >> Simon,
>
> > > >> I think this should be taken up with developers of these apps.
>
> > > >> In particular, my recommendations to them would be:
>
> > > >> - Use a startForeground / setForeground call to mark the service as
> > > >> being important to the user, do it only while the user is logged in.
>
> > > >> - Display a notification the phone's status bar, so the user knows if
> > > >> the service is still kicked out of memory.
>
> > > >> - Consider using AlarmManager to restart the service and re-login if
> > > >> there is an active logged in session.
>
> > > >> -- Kostya
>
> > > >> 23.06.2010 20:07, Simon Broenner пишет:
>
> > > >>> 1. Why am I, the user, not informed the the application has died, and
> > > >>> hence, the connection has been lost?
> > > >>> 2. Why are all the IM apps being killed, and not my other background
> > > >>> apps? Sipdroid and Locale have NEVER been killed in this fashion.
>
> > > >> --
> > > >> Kostya Vasilev -- WiFi Manager + pretty widget 
> > > >> --http://kmansoft.wordpress.com
>
> > > --
> > > Kostya Vasilev -- WiFi Manager + pretty widget 
> > > --http://kmansoft.wordpress.com-ZitiertenText ausblenden -
>
> > > - Zitierten Text anzeigen -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to