Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Service makes Activity not responding

Tags:

android

anybody knows what can be the reason for when i start a service from an Activity, the emulator shows a message "the activity is not responding?"

Inside my Service i start 2 threads in order to make some tasks. can be this the cause of the problem?

Thanks

like image 760
Gerardo Avatar asked Oct 22 '25 14:10

Gerardo


1 Answers

anybody knows what can be the reason for when i start a service from an Activity, the emulator shows a message "the activity is not responding?"

Because something in your application -- the activity, the service, etc. -- is tying up the main application thread.

Inside my Service i start 2 threads in order to make some tasks. can be this the cause of the problem?

Not directly, no, though you really should consider using AsyncTask rather than forking your own threads

Doing long-running work on the main application thread, or tying it up with a sleep() or busy-loop, will cause this exception.

like image 156
CommonsWare Avatar answered Oct 25 '25 04:10

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!