能否在ACTION_USER_ preSENT的BroadcastReceiver没有在清单中注册? [英] Can an ACTION_USER_PRESENT BroadcastReceiver not be registered in the manifest?

查看:138
本文介绍了能否在ACTION_USER_ preSENT的BroadcastReceiver没有在清单中注册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到,多个广播( 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">提交了一份文档错误在这个问题上

Correct -- neither ACTION_SCREEN_ON nor ACTION_USER_PRESENT can be registered in the manifest. I have filed a documentation bug on this issue.

这篇关于能否在ACTION_USER_ preSENT的BroadcastReceiver没有在清单中注册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆