3

I want to schedulers background service to run a scan method. so the service will update the number of scanned file. how can i handle the case that i closed the app schedulers run the service, the update ui method will crash and stop running the service.

Basbous
  • 3,927
  • 4
  • 34
  • 62

2 Answers2

3

According to my case

I changed the structure to let the service to send a broadcast and receive it in the activity.

Basbous
  • 3,927
  • 4
  • 34
  • 62
  • 3
    How often u send data from service to activity? How this influence performance if u send it let's say 10x per second? 10q – Ewoks Feb 12 '13 at 09:20
1

See this link. Its a very good example of Service. It illustrates both way communication.

Community
  • 1
  • 1
jamael
  • 398
  • 1
  • 4
  • 13
  • i change the structure to let the service to send a broadcast and receive it in the activity – Basbous May 12 '12 at 16:15
  • you really don't need to send a broadcast from service to transfer data. There is `ServiceConnection` and `Messenger`class to help you do that specific job. But thats ok if it works! :) – jamael May 13 '12 at 09:56
  • ServiceConnection still alive when i closed the activity ?? – Basbous May 18 '12 at 22:59