Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何调试启动接收器?_Java_Android_Broadcastreceiver - Fatal编程技术网

Java 如何调试启动接收器?

Java 如何调试启动接收器?,java,android,broadcastreceiver,Java,Android,Broadcastreceiver,我有以下接收器,在设备启动时,我的应用程序崩溃 因为它发生在引导时,所以我无法通过eclipse附加调试,也无法在logcat中看到任何内容 您建议我如何查看导致崩溃的错误 public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(Context arg0, Intent intent) { // TODO Auto-generated method

我有以下接收器,在设备启动时,我的应用程序崩溃

因为它发生在引导时,所以我无法通过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");
                    }
                }

        }
    }
}
我已尝试添加此尝试捕获

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 intent,并获得了拒绝权限

您可以在命令行中使用ADB在设备启动时记录日志

确保增加命令窗口可以显示的数据量,或者使用选项将日志保存到文件中

使用此方法,您可能会在启动时的日志中看到崩溃


编辑:我已经试过了,这是可能的,这应该对你有用

你不能自己发送一个意图,并将操作设置为intent.action\u BOOT\u完成吗?环境不会完全相同,但第一次尝试就足够了。@Kedarnath不是Log.e吗?你什么意思?@suauhwang我试图发送BOOT_完整的意图,但我被拒绝了