手机重启(重启)后,哪个接收者首先在android中被调用

时间:2019-06-25 08:36:00

标签: android broadcastreceiver

接收器的顺序是什么? 像BOOT_COMPLETED,MEDIA_MOUNTED等

1 个答案:

答案 0 :(得分:-1)

I have tested this. Please see the result -
This is the code snippet - 

<receiver
android:name=".CallReceiver"
android:enabled="true"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

This is the output - 


04-19 14:26:32.918 E/CallReceiver: onReceive android.intent.action.NEW_OUTGOING_CALL
04-19 14:26:34.571 E/CallReceiver: onReceive android.intent.action.PHONE_STATE
04-19 14:26:34.665 E/CallReceiver: CURRENT STATE IDLE
^^^^^ Why idle event? Why not offhook?
04-19 14:26:35.880 E/CallReceiver: onReceive android.intent.action.PHONE_STATE
04-19 14:26:35.969 E/CallReceiver: CURRENT STATE OFFHOOK
04-19 14:26:36.980 E/CallReceiver: onReceive android.intent.action.PHONE_STATE
04-19 14:26:37.064 E/CallReceiver: CURRENT STATE IDLE
<---- Where android.intent.action.NEW_OUTGOING_CALL event is?
04-19 14:26:38.742 E/CallReceiver: onReceive android.intent.action.PHONE_STATE
04-19 14:26:38.856 E/CallReceiver: CURRENT STATE OFFHOOK
04-19 14:26:39.273 E/CallReceiver: onReceive android.intent.action.PHONE_STATE
04-19 14:26:39.367 E/CallReceiver: CURRENT STATE IDLE
<---- Where android.intent.action.NEW_OUTGOING_CALL event is?
04-19 14:26:40.812 E/CallReceiver: onReceive android.intent.action.PHONE_STATE
04-19 14:26:40.891 E/CallReceiver: CURRENT STATE OFFHOOK
04-19 14:26:41.094 E/CallReceiver: onReceive android.intent.action.PHONE_STATE
04-19 14:26:41.199 E/CallReceiver: CURRENT STATE IDLE