【发布时间】:2017-10-14 08:38:38
【问题描述】:
我的应用程序在返回 START_STICKY 后立即崩溃。
我的应用程序中有前台服务:
public class MyService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
if (intent.getAction().equals(STARTFOREGROUND_ACTION)) {
// Code to create/update notification and start processing goes here
} else if (intent.getAction().equals(ANOTHER_ACTION)) {
// Code to create/update notification and do another processing
} else if (null != intent && intent.getAction().equals(STOPFOREGROUND_ACTION)) {
stopForeground(true);
stopSelf();
}
}
return START_STICKY; // Last reference point in debugger after which application crashes
}
}
我尝试调试只有最后一点是返回 START_STICKY;专门用于 STOPFOREGROUND_ACTION 信号,之后它会崩溃。
没有错误,警告显示在应用程序日志中,无法找出可能出了什么问题。
我能做些什么来解决这个问题是我停止前台服务的方式是错误的,我还能做些什么来获得更多特定于应用程序的日志。
我在任何地方都检查了我的代码,我发现异常并将它们记录如下:
try {
// Code expected to throw error or exception
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
应用程序中没有我绕过异常的地方,它们被缓存并记录在任何地方。
当我禁用所有过滤器并在 log cat 上选择详细选项时看到的一些错误:
1] `A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x10 in tid 32152 (Thread-1910)`
2]com.my.test.MyActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
3][Application Error: com.my.test](this:0xb28d3c00,id:809,api:1,p:933,c:252) new GraphicBuffer needed
4]I/WindowState: WIN DEATH: Window{41e99c5 u0 com.my.test.MyActivity}
【问题讨论】: