如果应用程序没有启动ATLEAST一次ICS广播接收器不工作 [英] Broadcast receiver not working in ICS if the app is not started atleast once

查看:109
本文介绍了如果应用程序没有启动ATLEAST一次ICS广播接收器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经被问几次堆栈溢出,但没有解决办法,但。 我有一个广播接收器,用于接收USB连接action.The广播接收机的责任是,如果我的意图开始我application.In我已经添加了接收器清单文件。 我也有同样的逻辑在姜饼的工作,但我ICS它不工作。 许多问题,比如, <一href="http://stackoverflow.com/questions/9596579/broadcastreciever-not-working-while-phone-is-booting-in-android">broadcast-not-invoking

<一个href="http://stackoverflow.com/questions/9596579/broadcastreciever-not-working-while-phone-is-booting-in-android">1: Android的引导进行广播不调用和<一href="http://stackoverflow.com/questions/9596579/broadcastreciever-not-working-while-phone-is-booting-in-android">broadcastreciever-not-working

如果我启动我的应用程序手动一次,然后下一次,病房时,USB连接我的应用程序将自动启动。 试图回答同样的问题,但没有答案。 对此有ICS中的任何解决方案?

这是我的接收机

 &LT;接收器的Andr​​oid版本:NAME =com.test.MyReceiver&GT;
                &LT;意向滤光器&gt;
                    &lt;作用机器人:名称=android.hardware.usb.action.USB_STATE/&GT;
                    &lt;作用机器人:名称=android.net.wifi.STATE_CHANGE/&GT;
            &lt;作用机器人:名称=android.net.wifi.WIFI_STATE_CHANGED/&GT;
            &lt;作用机器人:名称=android.hardware.usb.action.USB_DEVICE_ATTACHED/&GT;
            &lt;作用机器人:名称=android.hardware.usb.action.USB_DEVICE_ATTACHED/&GT;
                &所述; /意图滤光器&gt;
            &LT; /接收器&GT;
    这是我的课
    公共类MyReceiver扩展的BroadcastReceiver {
    。
    。
    。

  公共无效的onReceive(上下文的背景下,意图意图){
。
 

我错哪儿了吗?

在此先感谢 --Kozlov

解决方案
  

对此有ICS中的任何解决方案?

这是正常工作。由于安卓3.1的,没有的BroadcastReceiver 将工作,直到用户手动发起的活动。 我的博客上讲述这8个月前

This question has been asked few times in stack overflow, but no solution, yet. I have a broadcast receiver for for receiving USB connected action.The broadcast receiver responsibility is , if I get the intent start my application.In the manifest file I have added the receiver . I have the same logic working in GingerBread, but I ICS its not working. Many questions like , broadcast-not-invoking

1: Android Boot-Up BroadCast Not invoking and broadcastreciever-not-working

If I start my app manually once, then from next time on-wards when USB is connected my App starts automatically. tries to answer the same question but no answer. Is there any solution for this in ICS?

This my receiver

        <receiver android:name="com.test.MyReceiver">
                <intent-filter>
                    <action android:name="android.hardware.usb.action.USB_STATE" />
                    <action android:name="android.net.wifi.STATE_CHANGE" />
            <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
                </intent-filter>
            </receiver>
    and this is my class
    public class MyReceiver extends BroadcastReceiver {
    .
    .
    .

  public void onReceive(Context context, Intent intent) {
.

Am i wrong anywhere?

Thanks in advance --Kozlov

解决方案

Is there any solution for this in ICS?

It is working correctly. As of Android 3.1, no BroadcastReceiver will work until the user has manually launched an activity. I blogged about this eight months ago.

这篇关于如果应用程序没有启动ATLEAST一次ICS广播接收器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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