如何在 Android 模拟器中更改移动国家代码 (MCC)? [英] How do I change the Mobile Country Code (MCC) in the Android Emulator?

查看:31
本文介绍了如何在 Android 模拟器中更改移动国家代码 (MCC)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Android 应用程序需要对不同的移动国家代码做出不同的反应.

My Android application needs to react differently to different Mobile Country Codes.

它似乎被硬编码为 mcc310 (US).我可以从 TelephonyManager.getSimCountryIso() 或使用像 res/values-mcc123/ 这样的资源文件夹读取此值,但如何在模拟器中设置此值?

It seems like it is hardcoded to mcc310 (US). I can read this value from TelephonyManager.getSimCountryIso() or by using a resource folder like res/values-mcc123/ but how do I set this value in the emulator?

推荐答案

要更改 TelephonyManager.getSimCountryIso() 返回的内容,只需执行

To change what TelephonyManager.getSimCountryIso() returns, simply execute

adb shell setprop gsm.sim.operator.iso-country no

现在它返回 no(挪威).

and it now returns no (Norway).

如果你想改变 TelephonyManager.getSimOperator() 返回的内容 (MCC+MNC) 然后执行

If you want to change what TelephonyManager.getSimOperator() returns (MCC+MNC) then execute

adb shell setprop gsm.sim.operator.numeric 24201

您已将 MCC 更改为 242(挪威),将 MNC 更改为 01(Telenor).

and you have changed MCC to 242 (Norway) and MNC to 01 (Telenor).

查看可以更改的其他属性然后执行

To see which other properties you can change then execute

adb shell getprop

这经验证可在 AVD 和 Genymotion 上运行.但是,这不会永久更改这些属性.

This is verified to work on both AVD and Genymotion. However, this does not change these properties persistently.

这篇关于如何在 Android 模拟器中更改移动国家代码 (MCC)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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