IntentService无法从清单注册中获取Intent [英] IntentService not getting Intents from manifest registration

查看:88
本文介绍了IntentService无法从清单注册中获取Intent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此IntentService(摘录中的NotificationService)没有开始,并且没有收到这些Intent.通过在Application类中为它们注册一个接收器,我已经验证了这些Intent正在被广播.我只想在应用程序未启动时获取它们.

This IntentService (NotificationService in the snippet) isn't getting started and doesn't receive those Intents. By registering a receiver for them in the Application class, I've verified that those Intents are being broadcast. I just want to get them when the app isn't started.

    <service
        android:name=".services.NotificationService">
        <intent-filter>
            <action android:name="com.redactedtoprotecttheinnocent.ACTION_INCOMING_CALL"/>
            <action android:name="com.redactedtoprotecttheinnocent.ACTION_CALL_STATUS_CHANGE"/>
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </service>

这里有什么问题的建议吗?我不想创建广播接收器只是为了启动IntentService.

Any suggestions for what might be wrong here? I'd rather not create a broadcast receiver just to start an IntentService.

推荐答案

这里有什么问题的建议吗?

Any suggestions for what might be wrong here?

您似乎在想服务是通过广播Intents自动启动的,不是这种情况.

You appear to be thinking that services are started automatically by broadcast Intents, which is not the case.

我不想创建广播接收器只是为了启动IntentService.

I'd rather not create a broadcast receiver just to start an IntentService.

好吧,欢迎您重写发送com.redactedtoprotecttheinnocent.ACTION_INCOMING_CALLcom.redactedtoprotecttheinnocent.ACTION_CALL_STATUS_CHANGE广播的代码,以便它们停止发送广播,而使用startService()将命令发送到您的服务.但是,如果此代码不是您的代码,则更改它可能会很困难.

Well, you are welcome to rewrite the code that is sending com.redactedtoprotecttheinnocent.ACTION_INCOMING_CALL and com.redactedtoprotecttheinnocent.ACTION_CALL_STATUS_CHANGE broadcasts, so that they stop sending broadcasts, and instead use startService() to send commands to your service. If this code is not yours, though, changing it may be difficult.

或者,您也可以在清单清单中注册一个简短的BroadcastReceiver,该清单会转过来并调用startService()以使服务处理广播.

Or, you can have a short manifest-registered BroadcastReceiver that turns around and calls startService() to have the service process the broadcasts.

这篇关于IntentService无法从清单注册中获取Intent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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