通话判断卡槽

PhoneStateListener

onCallStateChangedExt(String, int, int)第三个int就是卡槽id.

<h>dd</h>

 

<div>

 

<h1>dddd

</div>

<html>
<h>
sd
</h>
</html>

4.2.2(8.0设备不支持!)

Protected void onReceive(Context c, Intent i)
   {
     Int whichSim = intent
      getIntExtra("simSlot",-1);
      // so this methof return 0            for sim 1 and 1 for sim2
     If(whichSim==-1)
    WhichSim=intent.getIntExtra("com.androie.phone.extra.slot",-1);
     }

 

intent 中带的数据

 

10-26 13:50:20.289 7763-7763/ I/phone_receiver: slot2 >android.intent.extra.PHONE_NUMBER

10-26 13:50:20.425 7763-7763/ I/phone_receiver: slot2 >incoming_number

10-26 13:50:20.425 7763-7763/ I/phone_receiver: slot2 >state

 

5.1.1以后。。。

    MultiSimTelephonyManager mtm;

 

 

…………………………………………………………………………………………

 

 

通过号码获取相应subId ?

//

添加action拦截

 

(支持所有版本)

 <action android:name="android.intent.action.SERVICE_STATE" />

 

 

卡一拨打,挂断都可以打印;

卡二只在挂断后打印;

 

10-26 16:19:57.266 14217-14217/? I/phone_receiver: slot2 >radioTechnology

10-26 16:19:57.266 14217-14217/? I/phone_receiver: slot2 >data-operator-alpha-long

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >operator-alpha-long

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >operator-numeric

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >manual

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >cdmaDefaultRoamingIndicator

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >cssIndicator

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >emergencyOnly

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >slot

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >LteEarfcnRsrpBoost

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >subscription

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >isDataRoamingFromRegistration

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >data-operator-numeric

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >dataRegState

10-26 16:19:57.267 14217-14217/? I/phone_receiver: slot2 >dataRoamingType

10-26 16:19:57.268 14217-14217/? I/phone_receiver: slot2 >isUsingCarrierAggregation

10-26 16:19:57.268 14217-14217/? I/phone_receiver: slot2 >voiceRegState

10-26 16:19:57.268 14217-14217/? I/phone_receiver: slot2 >dataRadioTechnology

10-26 16:19:57.268 14217-14217/? I/phone_receiver: slot2 >cdmaRoamingIndicator

10-26 16:19:57.268 14217-14217/? I/phone_receiver: slot2 >voiceRoamingType

10-26 16:19:57.268 14217-14217/? I/phone_receiver: slot2 >data-operator-alpha-short

10-26 16:19:57.268 14217-14217/? I/phone_receiver: slot2 >systemId

10-26 16:19:57.268 14217-14217/? I/phone_receiver: slot2 >networkId

10-26 16:19:57.268 14217-14217/? I/phone_receiver: slot2 >operator-alpha-short

 

 

信息中有slot id。

 

 

单张卡都可以在拨打前获取slot信息

 

 

 

……………………………………………………………………………………………………………………………………

 

方案二(支持6.0 以上):

通过拦截 <action android:name="android.intent.action.SUBSCRIPTIONPHONESTATE" /> 的广播做判断。 当android设备有卡处于接听/拨号状态时,系统都会发送广播。

通过 slot可以获取到通话的卡槽信息。

slot = intent.getIntExtra("slot", -1);

slot=0,表示卡槽一。slot=2表示卡槽二。

这个方案无论是卡一、卡二,拨打、来电和挂断时都可以拦截到广播,且并能读取到slot信息。建议使用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值