我有以下Reciever,我在设备启动时遇到应用程序崩溃。
由于它在启动时发生,我无法通过eclipse附加调试,也无法在logcat中看到任何内容。
您如何建议我看到导致崩溃的错误?
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent intent) {
// TODO Auto-generated method stub
if (intent != null) {
String action = intent.getAction();
if (action != null) {
if (action.equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) {
// GeoPushService geoPs = new GeoPushService();
ZoomerLocationService locService = new ZoomerLocationService();
locService.startService(new Intent());
// Log.d("receiver","action is: boot");
}
}
}
}
}
我尝试添加此try-catch
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent intent) {
// TODO Auto-generated method stub
if (intent != null) {
String action = intent.getAction();
try {
if (action != null) {
if (action.equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) {
// GeoPushService geoPs = new GeoPushService();
ZoomerLocationService locService = new ZoomerLocationService();
locService.startService(new Intent());
// Log.d("receiver","action is: boot");
}
}
} catch (Exception ex) {
Log.e(MyLogger.TAG, ex.getStackTrace().toString());
}
}
}
}
但它没有帮助
我试图发送BOOT_COMPLETE意图并获得权限拒绝
答案 0 :(得分:0)
您可以在命令行中使用ADB来记录设备启动时的logcat。
http://developer.android.com/tools/help/logcat.html
http://www.herongyang.com/Android/Debug-adb-logcat-Command-Option-Log-Buffer.html
确保增加命令窗口可以显示的数据量,或者使用选项将日志保存到文件中。
使用此方法,您可能会在启动日志中看到崩溃。
编辑:我已经尝试了这个,这有可能,这对你有用