我有一个启动完整的广播接收器,当手机重启时没有被调用,所以我从onReceive方法中删除了所有内容,添加了一个日志语句并使用ADB shell发送BOOT_COMPLETE广播,现在应用程序只关闭而没有任何消息当我发送广播并且应用程序的状态在logcat包下拉列表中转到DEAD。 我在我的清单文件中定义了以下权限:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
以下是我注册接收器的方式:
<receiver
android:name=".BootCompleteBroadcastReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
我试过没有android:exported =&#34; true&#34;标签。 我在onReceive方法中什么也没做,我只是有一个没有打印的日志语句。
这里是logcat,应用程序似乎以某种方式强制关闭,没有任何错误:
04-24 19:34:28.639 768 1645 D ReceiverController: getBootReceiverEnabledSetting(com.vysh.theeye) at User(0) with identity: 1001
04-24 19:34:28.639 898 898 D AppChangedReceiver: kill back service:com.vysh.theeye
04-24 19:34:28.642 768 1633 V PackageController: forceStopPackage: com.vysh.theeye
04-24 19:34:28.642 768 1633 I ActivityManager: Force stopping com.vysh.theeye appid=10119 user=0: from pid 768
04-24 19:34:28.643 768 1633 I ActivityManager: Killing 31461:com.vysh.theeye/u0a119 (adj 0): stop com.vysh.theeye
04-24 19:34:28.696 195 822 I BufferQueueProducer: [com.vysh.theeye/com.vysh.theeye.MainActivity](this:0xb4dd5000,id:270,api:1,p:-1,c:195) disconnect(P): api 1
04-24 19:34:28.697 195 822 I BufferQueueConsumer: [com.vysh.theeye/com.vysh.theeye.MainActivity](this:0xb4dd5000,id:270,api:1,p:-1,c:195) getReleasedBuffers: returning mask 0xffffffffffffffff
04-24 19:34:28.697 768 3699 I WindowState: WIN DEATH: Window{a34299a u0 com.vysh.theeye/com.vysh.theeye.MainActivity}
04-24 19:34:28.697 768 3699 V WindowManager: Remove Window{a34299a u0 com.vysh.theeye/com.vysh.theeye.MainActivity} client=1866e45, surface=Surface(name=com.vysh.theeye/com.vysh.theeye.MainActivity) Callers=com.android.server.wm.WindowState$DeathRecipient.binderDied:1217 android.os.BinderProxy.sendDeathNotice:566 <bottom of call stack> <bottom of call stack>
04-24 19:34:28.699 195 195 I BufferQueueConsumer: [com.vysh.theeye/com.vysh.theeye.MainActivity](this:0xb4dd5000,id:270,api:1,p:-1,c:-1) disconnect(C)
04-24 19:34:28.700 768 1633 D ActivityManager: SVC-handleAppDiedLocked: app = ProcessRecord{f2d64fb 31461:com.vysh.theeye/u0a119}, app.pid = 31461
04-24 19:34:28.702 195 821 I BufferQueue: [com.vysh.theeye/com.vysh.theeye.MainActivity](this:0xb4dd5000,id:270,api:1,p:-1,c:-1) ~BufferQueueCore
04-24 19:34:28.704 768 1633 W ActivityManager: Scheduling restart of crashed service com.vysh.theeye/.WatcherService in 10229ms
04-24 19:34:28.705 768 1633 D ActivityManager: removeDyingProviderLocked: cpr=ContentProviderRecord{6c3aebd u0 com.vysh.theeye/com.google.firebase.provider.FirebaseInitProvider} always=false inLaunching=false
04-24 19:34:28.705 768 1633 W ActivityManager: Force removing ActivityRecord{e3b6f3d u0 com.vysh.theeye/.MainActivity t2248}: app died, no saved state