gpt4 book ai didi

android - 如果应用程序未至少启动一次,则广播接收器无法在 ICS 中工作

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:25:28 24 4
gpt4 key购买 nike

这个问题在 stack overflow 中被问过几次,但还没有解决方案。我有一个用于接收 USB 连接操作的广播接收器。广播接收器的责任是,如果我得到 Intent 启动我的应用程序。在 list 文件中我添加了接收器。我在 GingerBread 中有相同的逻辑,但我 ICS 它不起作用。许多问题,例如, broadcast-not-invoking

1 : Android Boot-Up BroadCast Not invokingbroadcastreciever-not-working

如果我手动启动我的应用程序一次,那么从下次连接 USB 时起,我的应用程序会自动启动。试图回答同样的问题但没有答案。在 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) {
.

我哪里错了吗?

提前致谢--科兹洛夫

最佳答案

Is there any solution for this in ICS?

它工作正常。从 Android 3.1 开始,在用户手动启动 Activity 之前,BroadcastReceiver 将无法工作。 I blogged about this eight months ago .

关于android - 如果应用程序未至少启动一次,则广播接收器无法在 ICS 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9952562/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com