4

I am getting a

NullPointerException at android.app.ActivityThread$PackageInfo$ServiceDispatcher.doConnected(ActivityThread.java:1012)

My application is not even in the stack trace, so I have no idea what is going on.

I am trying to connect to a service when it happens.

How can I fix this problem?

1
  • Can we see a code snippet of you trying to connect to the service? Commented Jul 10, 2009 at 9:28

1 Answer 1

7

This probably way too old for my response to be of any use, but in case anybody else has this problem, here's what it was for me. I am using a newer version of the SDK, so I'm getting this issue at line 1061.

It was happening to me because I was passing a null ServiceConnection object to the function bindService.

It was helpful to browse the SDK code in my case - although the line numbers don't add up due to version differences, the general code is likely the same (and I knew which method to check):

1097                 // If there was an old service, it is not disconnected.
1098                 if (old != null) {
1099                     mConnection.onServiceDisconnected(name);
1100                 }
1101                 // If there is a new service, it is now connected.
1102                 if (service != null) {
1103                     mConnection.onServiceConnected(name, service);
1104                 }

mConnection was pretty much the only thing that made sense to be null.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.