Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

This means that your service is doing a rather long operation (most ANRs are from operations greater than 5 seconds) and is doing it on the UI thread. This could be a network task, or a database task, or some other long operation.

You can fix this by running the task in a service off the main UI thread, by using a Thread or an AsyncTask .

Infact, you can directly start your service into a new thread as follows:

Thread t = new Thread(){
public void run(){
getApplicationContext().bindService(
        new Intent(getApplicationContext(), YourService.class),
        serviceConnection,
        Context.BIND_AUTO_CREATE
t.start();

Also, cache the value returned by bindservice, if any, if you require it for later use.

Post the code of the service then. And try copy pasting the logcat. It's hard to read in your image. – Raghav Sood Oct 24, 2012 at 16:55 calling bindService() on a seperate thread didn't actually do the work on a seperate thread. – laim2003 Dec 18, 2020 at 12:12

Although there is an accepted answer but I want do add something additional here .The reason "Application Not Responding (ANR) executing service android" is that your Service does not finished it's lifecycle call (like onCreate) during the timeout . and the default timeout for a normal service is 20s . if you need an block operate in a Servcie onCreate you need start a new Thread or you can just use the IntentService .

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.