Broadcast receiver not working in ICS if the app is not started atleast once

拟墨画扇 提交于 2019-11-26 11:29:47

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/9952562/broadcast-receiver-not-working-in-ics-if-the-app-is-not-started-atleast-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!