简体   繁体   English

即使我的应用程序在 android 的后台,如何接收广播事件

[英]How to receive broadcast event even when my App is in background in android

I have a app which is a single activity app, it listens to many broadcast event, my question is that how can I ensure that I receive all the fired intent which i have added for my app even when my app is not in foreground and running in background??我有一个应用程序,它是一个单一的活动应用程序,它侦听许多广播事件,我的问题是,即使我的应用程序不在前台并正在运行,我如何确保我收到我为我的应用程序添加的所有触发意图在后台??

is there a certain method where I should add my intent filter and do the registerReciever?是否有某种方法我应该添加我的意图过滤器并执行 registerReciever? I'm sure it won't work if I keep it in "Oncreate"如果我将它保存在“Oncreate”中,我相信它不会起作用

any ideas or help??任何想法或帮助?

It sounds like you want to be using a BroadcastReceiver to pick up the events when you are in the 'background'.听起来您想在“后台”中使用 BroadcastReceiver 来接收事件。 This will pick up events which are actually broadcast without having to launch a UI.这将拾取实际广播的事件,而无需启动 UI。

You can set up the BroadcastReceiver and its intent filters in the manifest for your application, this way you dont have to rely on any java code being run to register the receivers.您可以在应用程序的清单中设置 BroadcastReceiver 及其意图过滤器,这样您就不必依赖任何正在运行的 java 代码来注册接收器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android:当应用程序处于非活动状态时,如何从服务接收广播 - android: how to receive broadcast from service when the app is inactive 即使我的应用程序不在前面,如何接收Bixby按钮按下事件? - How to receive a Bixby button press event, even if my app is not in front? Android广播接收器,每次应用启动时都会接收广播 - Android broadcast receiver, receive a broadcast every time when app launched 仅当APP在android中处于后台时如何激活广播接收器? - How to active Broadcast Receiver only when APP is in background in android? 当应用暂停或在后台时,避免接收广播接收器 - avoid to receive Broadcast Receiver when app is pause or in background 在后台进行活动时接收广播 - Receive the broadcast,when activity in background 应用在后台运行时的Android Broadcast Receiver - Android Broadcast Receiver when app is running in background 应用程序在后台时的 Android 广播接收器 - Android broadcast receiver when the app is in background 我该如何为Android应用注册TIME_TICK事件广播接收器,即使该应用是否正在运行 - how can i register TIME_TICK event broadcast receiver for android app even if app is running or not 如何在应用程序处于后台时收到消息? (Android,Unity,GCM) - How to receive a message when the app is in background? (Android, Unity, GCM)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM