Isa*_*ler 4 service android nullpointerexception android-activity
我得到了一个
NullPointerException at android.app.ActivityThread$PackageInfo$ServiceDispatcher.doConnected(ActivityThread.java:1012)
我的应用程序甚至没有在堆栈跟踪中,所以我不知道发生了什么.
我正试图在服务发生时连接到服务.
我该如何解决这个问题?
这对我的回答来说可能太旧了,但是如果有其他人有这个问题,这就是我的意思.我正在使用更新版本的SDK,所以我在第1061行遇到了这个问题.
它发生在我身上,因为我将一个null的ServiceConnection对象传递给函数bindService.
在我的案例中浏览SDK代码很有帮助 - 虽然由于版本差异而没有添加行号,但是一般代码可能是相同的(我知道要检查哪种方法):
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 }
Run Code Online (Sandbox Code Playgroud)
mConnection几乎是唯一有意义的null.
| 归档时间: |
|
| 查看次数: |
2642 次 |
| 最近记录: |