在android4.4手机里,先静态注册一次广播,之后在代码里动态注册一次该广播,会同时收到两次onReceive回调,我在htc 802d手机上测试(使用官方升级版,升级到4.4)测试
//第一次来电时间回调
I/SmsTest_CallReceiver(31843): onReceive | action = android.intent.action.PHONE_STATE
I/SmsTest_CallReceiver(31843): key = phone_slot, value = 11
I/SmsTest_CallReceiver(31843): key = phone_type, value = 1
I/SmsTest_CallReceiver(31843): key = incoming_number, value = 18963792291
I/SmsTest_CallReceiver(31843): key = state, value = RINGING
//第二次来电时间回调
I/SmsTest_CallReceiver(31843): onReceive | action = android.intent.action.PHONE_STATE
I/SmsTest_CallReceiver(31843): key = phone_slot, value = 11
I/SmsTest_CallReceiver(31843): key = phone_type, value = 1
I/SmsTest_CallReceiver(31843): key = incoming_number, value = 18963792291
I/SmsTest_CallReceiver(31843): key = state, value = RINGING
//第一次挂断电话回调
I/SmsTest_CallReceiver(31843): onReceive | action = android.intent.action.PHONE_STATE
I/SmsTest_CallReceiver(31843): key = phone_slot, value = 11
I/SmsTest_CallReceiver(31843): key = phone_type, value = 1
I/SmsTest_CallReceiver(31843): key = state, value = IDLE
//第二次挂挂断电话回调
I/SmsTest_CallReceiver(31843): onReceive | action = android.intent.action.PHONE_STATE
I/SmsTest_CallReceiver(31843): key = phone_slot, value = 11
I/SmsTest_CallReceiver(31843): key = phone_type, value = 1
I/SmsTest_CallReceiver(31843): key = state, value = IDLE
当我注释掉代码里的动态注册后,只收到一次回调
//第一次来电时间回调
I/SmsTest_CallReceiver(32260): onReceive | action = android.intent.action.PHONE_STATE
I/SmsTest_CallReceiver(32260): key = phone_slot, value = 11
I/SmsTest_CallReceiver(32260): key = phone_type, value = 1
I/SmsTest_CallReceiver(32260): key = incoming_number, value = 18963792291
I/SmsTest_CallReceiver(32260): key = state, value = RINGING
//第一次挂断电话回调
I/SmsTest_CallReceiver(32260): onReceive | action = android.intent.action.PHONE_STATE
I/SmsTest_CallReceiver(32260): key = phone_slot, value = 11
I/SmsTest_CallReceiver(32260): key = phone_type, value = 1
I/SmsTest_CallReceiver(32260): key = state, value = IDLE
本人自己是不是对注册进去的接受器未去重导致