Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 896
Kozlov Avatar asked Mar 31 '12 02:03

Kozlov


1 Answers

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.

like image 167
CommonsWare Avatar answered Oct 27 '22 21:10

CommonsWare