我已经阅读了很多帖子并尝试了许多解决方案,但所有帖子的共同点都是它们都过时了,至少我无法找到适用于较新版本Android的解决方案。
帖子1,结果:
intent.getExtras().getInt("simId", -1)
总是返回-1
帖子2,结果:
intent.getExtras().getInt("slot", -1)
总是返回-1
帖子3,结果:
String[] array = new String[]{
"extra_asus_dial_use_dualsim",
"com.android.phone.extra.slot",
"slot",
"simslot",
"sim_slot",
"subscription",
"Subscription",
"phone",
"com.android.phone.DialingMode",
"simSlot",
"slot_id",
"simId",
"simnum",
"phone_type",
"slotId",
"slotIdx"
};
for (String item :
array) {
Log.i(TAG, "Sim Card - " + item + " -----> " + intent.getExtras().getInt(item));
}
日志:
PhoneCallReceiver: Sim Card - extra_asus_dial_use_dualsim -----> 0
PhoneCallReceiver: Sim Card - com.android.phone.extra.slot -----> 0
PhoneCallReceiver: Sim Card - slot -----> 0
PhoneCallReceiver: Sim Card - simslot -----> 0
PhoneCallReceiver: Sim Card - sim_slot -----> 0
PhoneCallReceiver: Sim Card - subscription -----> 0
PhoneCallReceiver: Sim Card - Subscription -----> 0
PhoneCallReceiver: Sim Card - phone -----> 0
PhoneCallReceiver: Sim Card - com.android.phone.DialingMode -----> 0
PhoneCallReceiver: Sim Card - simSlot -----> 0
PhoneCallReceiver: Sim Card - slot_id -----> 0
PhoneCallReceiver: Sim Card - simId -----> 0
PhoneCallReceiver: Sim Card - simnum -----> 0
PhoneCallReceiver: Sim Card - phone_type -----> 0
PhoneCallReceiver: Sim Card - slotId -----> 0
PhoneCallReceiver: Sim Card - slotIdx -----> 0
它显示相同的日志,第一个Sim卡和第二个Sim卡的值为0。
我也尝试过其他类似的帖子。但在新版本的Android上都不起作用!
是否有另一种解决方案适用于较新版本的Android(7.0或更高版本)?
intent.getExtras().getInt("item")
<--你不应该使用"item"
而不是item
吗? - Michael