I assume you are calling Bind with Context.BIND_AUTO_CREATE flag to
start the system.

Try to explicitly call startService before calling bind.

Artak



On Mon, Dec 20, 2010 at 4:29 PM, Kalyan Akella <[email protected]> wrote:
> Hi,
>
> I have a scenario which requires the Android service from not getting
> destroyed when the Activity that started it (through bindService) calls the
> unbind. Here it goes...
>
> Step1: The main activity A, starts and renders the UI which contains some
> text and a button B.
> Step2. Inside the onCreate() method, A calls bindService and starts/binds to
> a certain service S (which by the way is an IntentService and a
> LocationListener).
> Step3: Back on the UI, on click of the button B, the activity A sends a
> certain message M to the service S.
> Step4: S reads the user's current geo-location and if a fix is available, it
> sends this message M along with this geo-location to a certain web service.
> Step5: But if the current geo-location (the last known location) is
> unavailable or if the web service is unreachable, it queues this message to
> send it across later.
> Step6: On the UI, the user might exit the application which causes A to do
> its onDestroy which in turn calls the unbindService() to unbind from S.
>
> Here's my problem. If the message wasn't sent in Step 5 by the service S and
> in Step 6 if the user exits the application, Android kills the service S
> because there's no one else bound to it and hence the message it was
> supposed to send is forever lost (unless I store it elsewhere to re-send it
> if the user restarts my application).
>
> So, is there a better way to do all this or is there a way to prevent S from
> getting destroyed if the message queue is not empty. Please help.
> Sincere Regards,
> Kalyan
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

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

Reply via email to