0

I have implemented a receiver like this (in the manifest file)

    <receiver android:name="com.phonelight.realparrot.RecorderBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.PHONE_STATE">        
             </action>
                 </intent-filter>
        </receiver>

If the state of the phone changes, the recorder broadcast receiver is invoked. Everything is fine. However, If I reboot the device, the receiver is never invoked until I run my application.

I need to register (not invoking) this receiver after booting.

Many thank,

[Edit]

I solved the problem by adding the following receiver to the Manifest file

   <receiver android:name="com.phonelight.realparrotpro.RecorderBroadcastReceiver">
                <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

I did not register the RecorderBroadcastReceiver in the java code though. I only added the above receiver. It means invoking anything from an app will register all the receivers written in the Manifest file.

yasserbn
  • 391
  • 3
  • 18

1 Answers1

0

You need to create a receiver for onBootComplete and then register your receiver there. This way your receiver will get registered even after reboot.

<receiver android:name="App_Receiver">
<intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

PravinCG
  • 7,688
  • 3
  • 30
  • 55
  • I did not register the receiver in the App_Receiver.java. It means invoking anything from an app (like a receiver) will register all the receivers written in the Manifest file. Correct? – yasserbn Dec 03 '12 at 23:17
  • App_Receiver is just a name, you can have any name to register it. You need to then register your other receivers. – PravinCG Dec 04 '12 at 05:26
  • It worked without implementing App_Receiver.java and register my broadcast receiver in it. As I wrote in the [Eidt], I only add the above receiver. Also, your approach may not work with me because there is a difference between registering a receiver in java and the XML file[link](http://stackoverflow.com/questions/10876015/broadcast-receiver-register-in-manifest-vs-activity). I would appreciate your help though. – yasserbn Dec 04 '12 at 15:22