I currently have a broadcast receiver for listening to call status events. I registered the broadcast receiver in AndroidManifest.xml as shown below.
<receiver android:name=".api.PhoneCallReceiver"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> </receiver>
When the application starts this broadcast receiver, it registers to listen to call status events and according to CALL_STATE I control my application.
It works fine until the phone restarts. After rebooting the phone, this broadcast receiver stops working. I know that I have to register a receiver to listen for the BOOT_COMPLETED system events.
What I did as shown below:
<receiver android:name=".api.PhoneCallReceiver"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver>
I also gave permission to receive the BOOT_COMPLETED system event.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
but somehow it doesn't work. I am thinking of creating a new broadcast receiver that listens only for the BOOT_COMPLETED event, but the problem is that
So my questions are: how can I run this broadcast call viewer receiver when an incoming call arrives?
How can I register a broadcast receiver from another broadcast receiver
Do I need to move the existing broadcast receiver code for maintenance so that I can get started with Boot Receiver?
Any help would be appreciated.
source share