如何在Android中使用反射从第二个SIM卡插槽发送短信? [英] How to use reflection in Android for sending sms from second sim slot?

查看:421
本文介绍了如何在Android中使用反射从第二个SIM卡插槽发送短信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过Android设备的第二个插槽发送短信.我搜索了很多遍,以找到一种通过第二个SIM卡插槽发送短信的解决方案.但是,没有针对此问题的任何常规解决方案.有人对移动设备的每个系列使用反射,以从第二个插槽发送短信.现在,我该如何使用反射来解决这个问题?

I need to send sms via second slot of an android device. I searched many times to find a solution for sending sms with second sim slot. But there is not any regular solution for this problem. Some people use reflection for each series of mobile devices for sending sms from second slot. Now, how can I use reflection for this problem?

推荐答案

您没有提到要定位的cookie,但是在Lollipop MR1中,您可以通过基于订阅获取SmsManager来与第二张SIM卡一起发送:

You don't mention which cookie you're targeting, but in Lollipop MR1 you can send with the second SIM card by fetching the SmsManager based on subscription:

http://developer.android.com/reference /android/telephony/SmsManager.html#getSmsManagerForSubscriptionId(int)

每张SIM卡在插入时都会分配一个订阅ID.这些ID和有关SIM的信息存储在TelephonyProvider的siminfo表中.这些ID从1开始.要获取有关当前活动的订阅ID的信息,请使用SubscriptionManager: http://developer.android.com/reference/android/telephony/SubscriptionManager.html

Every SIM card gets assigned a subscription ID when they are inserted. These IDs and information about the SIM are stored in the siminfo table in the TelephonyProvider. The IDs start from 1. To get information about what subscription IDs you currently have active, you use the SubscriptionManager: http://developer.android.com/reference/android/telephony/SubscriptionManager.html

方法getActiveSubscriptionInfoForSimSlotIndex获取SIM卡插槽索引(通常为0或1),并返回有关该SIM卡的订阅信息,包括可用于获取正确的SmsManager的订阅ID.

The method getActiveSubscriptionInfoForSimSlotIndex takes a SIM slot index (normally either 0 or 1) and returns subscription info about that SIM, including the subscription ID which you can use to fetch the right SmsManager.

如果您在Lollipop之前定位平台,则Google不会正式支持DS支持,而平台供应商(高通,联发科技等)很可能会添加DS支持,因此该API未记录在案.您可以通过调用SmsManager.class.getDeclaredMethods()来查询SmsManager的方法,但DS API可能在完全不同且未记录的类中.

If you're targeting platforms prior to Lollipop then the DS support is not officially supported by Google and it's most likely added by the platform vendor (Qualcomm, Mediatek etc.) so the API is undocumented. You can query the SmsManager for its methods by calling SmsManager.class.getDeclaredMethods(), but the DS API might be in a completely different and undocumented class.

这篇关于如何在Android中使用反射从第二个SIM卡插槽发送短信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆