能否在ACTION_USER_ preSENT的BroadcastReceiver没有在清单中注册?清单、preSENT、BroadcastReceiver

2023-09-04 06:37:57 作者:我并非良人

我看到,多个广播( ACTION_TIME_TICK ,例如)不能在清单中注册时,必须明确地通过注册Context.registerReceiver()。我有与 ACTION_USER_ preSENT 广播意图。具体而言,我测试的仿真器和我的应用程序保持力缩小与错误:

I see that multiple broadcasts (ACTION_TIME_TICK, for example) cannot be registered in the manifest, the must be explicitly registered via Context.registerReceiver(). I am having trouble with the ACTION_USER_PRESENT broadcast intent. Specifically, I test on the emulator and my application keeps force closing with the error:

08-30 09:44:23.397: ERROR/AndroidRuntime(290): java.lang.RuntimeException: Unable to start receiver me.turnerha.RegisterListeners: java.lang.IllegalArgumentException: Receiver not registered: me.turnerha.RegisterListeners@43d05690

这是由

08-30 09:44:23.397: ERROR/AndroidRuntime(290): Caused by: java.lang.IllegalArgumentException: Receiver not registered: me.turnerha.RegisterListeners@43d05690

我的清单是相当简单:

My manifest is fairly simple:

    <receiver android:name=".RegisterListeners">
        <intent-filter>
            <action android:name="android.intent.action.SCREEN_ON" />
        </intent-filter>
    </receiver>

有什么想法?我基本上是试图创建一个我的应用程序在安装后立即惊醒地接收器。第一次被唤醒,它注册了一些听众,然后注销本身,以便它永远不会再次调用。 (我真的很希望有意向马上还以颜色已经安装了您的应用程序后,允许设置一个小一点的:))

Any thoughts? I am essentially attempting to create a Receiver that is awakened as soon as possible after my application is installed. The first time it is awakened, it registers a few listeners, and then it unregisters itself so it is never called again. (I really wish there was an intent fired immediately after your app had been installed, to allow a small bit of setup :) )

推荐答案

正确的 - 既不 ACTION_SCREEN_ON ACTION_USER_ preSENT 可以在清单中注册。我有rel="nofollow">提交了一份文档错误在这个问题上