如果应用程序至少没有启动一次,则广播接收器无法在 ICS 中工作 [英] Broadcast receiver not working in ICS if the app is not started atleast once

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

问题描述

这个问题在堆栈溢出中被问过几次,但还没有解决方案.我有一个广播接收器,用于接收 USB 连接的动作.广播接收器的责任是,如果我得到意图启动我的应用程序.在清单文件中,我添加了接收器.我在 GingerBread 中有相同的逻辑,但我的 ICS 不起作用.许多问题,例如,广播不调用

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 启动广播不调用broadcastreciever-not-working

如果我手动启动我的应用程序一次,那么从下一次连接 USB 时我的应用程序会自动启动.试图回答同样的问题,但没有答案.ICS 中是否有任何解决方案?

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?

这是我的接收器

        <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) {
.

我哪里错了?

提前致谢--科兹洛夫

推荐答案

ICS 中是否有任何解决方案?

Is there any solution for this in ICS?

它工作正常.从 Android 3.1 开始,在用户手动启动 Activity 之前,BroadcastReceiver 将无法工作.我在八个月前写了关于这个的博客.

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.

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

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