当我杀了我的应用程序的BroadcastReceiver不工作 [英] BroadcastReceiver not working when I kill my application

查看:137
本文介绍了当我杀了我的应用程序的BroadcastReceiver不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到不是每当我手动杀由长$ P $我的应用程序pssing我的手机我的广播接收器停止工作的后退按钮。接收机负责每个用户挂断电话呼叫和相同的被登记在manifest.xml时间显示一通知的

这是正常/预期的行为?我以为接收机应继续工作,即使用户决定要杀死我的应用程序...有没有一种方法,以prevent呢?

感谢。

修改

下面是接收器清单条目:

 <接收机器人:BroadcastReceivers.CallReceiver名称=机器人:启用=真正的>
   <意向滤光器>
       <作用机器人:名称=android.intent.action.NEW_OUTGOING_CALL/>
       <作用机器人:名称=android.intent.action.PHONE_STATE/>
   &所述; /意图滤光器>
< /接收器>
 

解决方案

有〜7个十亿人在这个星球上。只有你自己知道你所说的杀的意思。

这是你所描述的症状,不过,与强制停机是一致的。用户通常通过去设置,发现在已安装的应用程序列表中选择您的应用程序,并点击该强制停机按钮,您的应用程序强行停止的应用程序。有一些设备和固件建立了使强制停止比这更容易获得 - 这样的设备和固件构建写的流口水白痴恕我直言

如果你的程序是强制停止,你的code永远不会再运行,直到一些使用明确的意图来开始你的组件之一。通常情况下,用户通过点击在主屏幕的启动您的应用程序的图标做到这一点。直到用户这样做,你的的BroadcastReceiver 将无法正常工作,并且有,你可以做些什么。

而不是使用一些设备上的功能来杀你的应用程序,尝试通过DDMS终止其进程。如果您的应用程序将继续在这种情况下工作,那么无论你当选为杀你的应用程序之前,做一个强制停机。空有你的进程被终止,如因内存不足的情况​​,不应该接收将来的广播prevent你。

I have noticed than whenever I manually kill my application by longpressing the back button of my cellphone my broadcast receiver stops working. The receiver is in charge of displaying a notification every time the user hangs up a phone call and the same is registered in the manifest.xml.

Is this the normal/expected behaviour? I thought the receiver should continue to work even if the user decides to kill my application... Is there a way to prevent this?

Thanks.

Edit

Here's the manifest entry for the receiver:

<receiver android:name=".BroadcastReceivers.CallReceiver" android:enabled="true">
   <intent-filter>
       <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
       <action android:name="android.intent.action.PHONE_STATE" />
   </intent-filter>
</receiver>

解决方案

There are ~7 billion people on the planet. Only you know what you mean by "kill".

The symptoms that you are describing, though, are consistent with a "force stop". A user normally force-stops an application by going to Settings, finding your app in the list of installed apps, and tapping on the "Force Stop" button for your app. There are some devices and firmware builds that make "Force Stop" more readily accessible than this -- such devices and firmware builds were written by drooling idiots IMHO.

If your app is force-stopped, your code will never run again, until something uses an explicit Intent to start one of your components. Usually, the user does this by tapping on your app's icon in the home screen's launcher. Until the user does this, your BroadcastReceiver will not work, and there is nothing you can do about it.

Rather than using some on-device feature to "kill" your app, try terminating its process via DDMS. If your app continues to work in that case, then however you elected to "kill" your app before is doing a "force-stop". Merely having your process be terminated, such as due to low memory conditions, should not prevent you from receiving future broadcasts.

这篇关于当我杀了我的应用程序的BroadcastReceiver不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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