[android-developers] Re: How to keep service alive?

2009-07-31 Thread Guillaume Perrot
You can use setForeground(true) inside your service's onCreate() to make your Service considered important, the service won't be killed so often... HOWEVER it's recommended (see previous post from Dianne) that you show an ongoing notification while the service is alive (show in onCreate(), dismiss

[android-developers] Re: How to keep service alive?

2009-07-31 Thread Archana
Hi, I already tried with setForeground(true) method.But no use.Same error Also I tried without using service and background ... I used some views which contains some images.Then also i am getting same error. On Jul 31, 11:39 am, Guillaume Perrot guillaume.p...@gmail.com wrote: You can use

[android-developers] Re: How to keep service alive?

2009-07-31 Thread Archana
Anyone know this.Please help me out from this situation. On Jul 31, 11:58 am, Archana archana.14n...@gmail.com wrote: Hi, I already tried with setForeground(true) method.But no use.Same error Also I tried without using service and background ... I used some views which contains some

[android-developers] Re: How to keep service alive?

2009-07-30 Thread Archana
Hi , I am also facing the same issue.My app exiting automatically after showing this error message in logcat log - INFO/ActivityManager(56): Low Memory: No more background processes. can you tell me how to solve this.I am using thread in my app.so i thought may be it becoz of that. But after

[android-developers] Re: How to keep service alive?

2009-07-20 Thread Yossi
My code snippet was not full. I use ServiceConnection and do save the state of the service (binded/unbinded) to avoid unnecessary binding. Anyhow, thanks for the details. I believe I know now how to rewrite me code. Yossi On Jul 19, 11:49 pm, Dianne Hackborn hack...@android.com wrote: The

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Mark Murphy
Yossi wrote: Is it possible to keep service alive even if the foreground app does not run anymore? Yes, for a while anyway. My app consists of a foreground app (UI) and a service that should keep running in the background until it is being explicitly stopped by the user (similar to a music

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Yossi
Hi Mark, My code is relatively simple public void onResume() { Intent intent = new Intent(this, TrackingService.class); startService(intent); bindService(intent, _connection, Context.BIND_AUTO_CREATE); } public void onPause() { if(shouldStopService()) {

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Mark Murphy
Yossi wrote: Hi Mark, My code is relatively simple public void onResume() { Intent intent = new Intent(this, TrackingService.class); startService(intent); bindService(intent, _connection, Context.BIND_AUTO_CREATE); } Do either startService() or bindService(), not

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Guillaume Perrot
Using both startService and bindService is handy to wait for the onServiceConnected callback before requesting a singleton reference that is set in the service's onCreate. If you do this just after the startService, the reference will be null. The startService is needed for the service to

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Mark Murphy
Guillaume Perrot wrote: Using both startService and bindService is handy to wait for the onServiceConnected callback before requesting a singleton reference that is set in the service's onCreate. If you do this just after the startService, the reference will be null. Correct, because

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Guillaume Perrot
I was not aware of the overhead issue with a local Binder, I thought this case was optimized. I hope the Android team will work on this so that we won't have to reinvent the wheel. I will look at your code once it'll be available, this sounds interesting. 2009/7/19 Mark Murphy

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Dianne Hackborn
Ultimately calls through a binder object are a direct function call. Most of my comments along these lines have been about defining aidl interfaces for communicating with local services, which is a waste (there is lots of generated code that will never be used), and a lot more work (you need to

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Dianne Hackborn
The onPause() method in this example is broken, because if shouldStopService() returns false then it won't unbind, and the next time the activity gets resume it will then go and re-build, causing a growing number of bindings. On Sun, Jul 19, 2009 at 7:58 AM, Guillaume Perrot

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Mark Murphy
Dianne Hackborn wrote: Ultimately calls through a binder object are a direct function call. Most of my comments along these lines have been about defining aidl interfaces for communicating with local services, which is a waste (there is lots of generated code that will never be used), and a

[android-developers] Re: How to keep service alive?

2009-07-19 Thread Guillaume Perrot
Actually I use a local service without aidl, I allocate a dummy binder (new Binder()) in onBind(). This service manages an XMPP connection, even if no screen is shown to user (there is an ongoing notification with a life cycle corresponding to the service's one, and so I guess my use of