views:

690

answers:

1

Hello,
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? Thanks, Isaac Waller

A: 

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.

ydant