经过对论坛的大量研究,现在我知道在双SIM卡手机中无法找到两张SIM卡的IMSI或SIM序列号(除了联系制造商).现在我改变的问题是,我们可以检测到手机有两个SIM吗?我相信它可以用一些智慧来检测.我能想到的几个方法是:
拨打USSD代码并跟踪IMEI号码的日志(我在印度尝试使用*139#.它有效.)这将给我SIM卡的IMEI号,我从中拨打了USSD代码.(假设手机遵循Android指南并且有两个IMEI号码.)
存储SIM的SIM序列号和/或IMSI.并且在检测到任何其他IMSI /序列号之后,即使手机没有重新启动(即SIM切换),也可以通过跟踪某些日志或某些广播事件处理来实现.
通过拨打*06#,您将看到两个IMEI号码.通过某种方式,获得这两个数字.(像屏幕捕获和文本图像解析之类的东西.)
如果有人能想到其他方式,他们是最受欢迎的.我真的很感激这方面的任何帮助.此外,如果任何人有关于任何制造商API或链接的任何信息,请与社区人员分享.
我有一个双卡通Android手机.我正在使用此代码拨打电话:
private void callBack(String phone, Context context) {
Intent callIntent = new Intent(Intent.ACTION_CALL)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
callIntent.setData(Uri.parse("tel:" + phone));
context.startActivity(callIntent);
}
Run Code Online (Sandbox Code Playgroud)
它工作正常.但它总是从sim1调用(最好是sim).如何从Sim2拨打电话?有没有办法处理双卡手机?
我能够捕获传入的ussd消息,但如何在双卡手机的情况下比较传入的ussd消息?如果我收到一条消息提示,我怎么知道传入的消息是针对哪个SIM卡?
如何使用双SIM卡支持模拟Android设备?Android级别为5.1或更高级别非常重要.此模拟器旨在发送/接收SMS
我试图在具有双Sim(两者都有效)的Android 5.1设备中获取MCC和MNC号码(基本上我想要IMSI号码但这些也足够了).由于5.1支持双Sim,所以我使用了这样的Subscription管理器:
SubscriptionManager manager = SubscriptionManager.from(this);
List<SubscriptionInfo> sil = manager.getActiveSubscriptionInfoList();
if (sil != null) {
for (SubscriptionInfo subInfo : sil) {
Log.v("TestMain", "SubInfo:" + subInfo);
}
} else {
Log.v("TestMain", "SubInfo: list is null");
}
Run Code Online (Sandbox Code Playgroud)
得到了这个输出:
07-24 18:28:32.162 3844-3844/? V/TestMain? SubInfo:{id=1, mcc 405 mnc 803, iccId=89918030914128062059 simSlotIndex=0 displayName=Aircel Karnataka carrierName=Aircel — Aircel Karnataka nameSource=0}
07-24 18:28:32.162 3844-3844/? V/TestMain? SubInfo:{id=2, mcc 405 mnc 803, iccId=8991860044481968955 simSlotIndex=1 displayName=CARD 2 carrierName=Vodafone Karnataka nameSource=0}
Run Code Online (Sandbox Code Playgroud)
MCC(将与同一个国家/地区相同)注意到虽然运营商不同,但MNC是相同的.
当我关掉手机时,我在logcat中看到了这一行:
07-24 18:31:02.295 616-616/? V/KeyguardUpdateMonitor? SubInfo:{id=1, mcc 405 mnc …Run Code Online (Sandbox Code Playgroud) android android-source telephonymanager dual-sim android-5.1.1-lollipop
对于单个SIM代码以下代码:
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String imei= tm.getDeviceId();
Run Code Online (Sandbox Code Playgroud)
对于双SIM卡,我在以下链接上尝试了代码:
但它对我没有用.
如果有任何其他解决方案,请告诉我.
我已经阅读了很多帖子并尝试了很多解决方案,但所有帖子的共同点是它们都已经过时了,至少我找不到适用于较新版本的 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));
}
Run Code Online (Sandbox Code Playgroud)
日志:
PhoneCallReceiver: Sim Card - extra_asus_dial_use_dualsim -----> 0
PhoneCallReceiver: Sim Card - com.android.phone.extra.slot -----> 0
PhoneCallReceiver: Sim Card …Run Code Online (Sandbox Code Playgroud) 我试图设置移动数据.但它只是起作用SIM 1.
public static void setMobileData(Context context, boolean isEnabled) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
ConnectivityManager conman = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
@SuppressWarnings("rawtypes")
final Class conmanClass = Class.forName(conman.getClass().getName());
final Field iConnectivityManagerField = conmanClass.getDeclaredField("mService");
iConnectivityManagerField.setAccessible(true);
final Object iConnectivityManager = iConnectivityManagerField.get(conman);
final Class iConnectivityManagerClass = Class.forName(iConnectivityManager.getClass().getName());
Class[] cArg = new Class[2];
cArg[0] = String.class;
cArg[1] = Boolean.TYPE;
Method setMobileDataEnabledMethod;
setMobileDataEnabledMethod = iConnectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", cArg);
Object[] pArg = new Object[2];
pArg[0] = context.getPackageName();
pArg[1] = isEnabled;
setMobileDataEnabledMethod.setAccessible(true);
setMobileDataEnabledMethod.invoke(iConnectivityManager, pArg);
}
public static void …Run Code Online (Sandbox Code Playgroud) 您只知道广播接收器中的SIM卡插槽号.经过一个月的研究,我得到了一个对我来说工作正常的解决方案,如下所示
首先将android.permission.READ_PHONE_STATE权限添加到清单文件中
为电话事件实现接收器,为您的应用程序接收呼叫/短信事件
public class CallSMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
Log.d("SIM_SLOT"," Slot Number "+capturedSimSlot(extras));
}
}
/*below methods captures the sim slot number from bundle */
public int capturedSimSlot(Bundle bundle){
int whichSIM =-1;
if (bundle.containsKey("subscription")) {
whichSIM = bundle.getInt("subscription");
}
if(whichSIM >=0 && whichSIM < 5){
/*In some device Subscription id is return as subscriber id*/
sim = ""+whichSIM;
}else{
if (bundle.containsKey("simId")) {
whichSIM …Run Code Online (Sandbox Code Playgroud)