问题描述
我的 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)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)