Search code examples
androidxmlservicemanifestbackground-process

Service not working?


I am building a game where I want the user to go through many activities in 20 seconds. Once the 20 seconds is over, I want to send the user to the GameOver screen. To run the timer in the background, I used a service. The issue is, the service doesn't seem to be running?

enter image description here

The weird thing is, that even the toast isn't showing. Here is the place where I call the service:

enter image description here

Here is the manifest:

enter image description here

Please let me know as to why the service or the timer aren't running. Thank you so much for all of your help, I really appreciate it! If you need any more code, just let me know and I will show you. Thanks!

:-)

{Rich}

Solution

  • Services can't interact with UI, which is what Toast does. If you want to do that, try using runOnUIThread along with getApplicationContext or the fancy way with binding/callbacks. Also, take a look at AlarmManager, might be a simpler solution instead of running a service.