It sounds like you are trying to fix the symptom of a problem rather than
address the actual issue.  The real question should be "Why does my service
get destroyed?"

Have you looked into why your service gets destroyed? What kind of service
are you using (hopefully not IntentService)?

On Fri, Apr 17, 2015 at 8:52 AM NewToAndroid <[email protected]> wrote:

> Hi all,
>
> I have a very simple app, which has 1 screen with few buttons. It will
> start a service which will pay music using mediaplayer.
> Now, sometimes if I go in no internet coverage area or move between 3g and
> wifi, the player stops and service completes (does its onDestroy).
>
> I am thinking of writting a simple loop, which will check if the service
> is running after every 10 secnds (or something like that) and if the
> service is down, it will start it.
> Question is, where should I write this loop in the activity code ? which
> method is better suited to have this loop which is continuously running ?
> onStart?
> Any other better ideas ? (I am sure there will be)
>
> Thanks in advance
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to