我正在实施应用程序内购买.在应用程序产品列表中,我为国家A配置了少量产品,为国家B配置了少量产品.因此,我的应用程序应仅显示为国家/地区A中的用户配置的国家/地区的产品.国家B中的用户.因此,当我的应用程序与我的内容服务器通信时,应用程序应该能够通过服务器请求发送设备国家/地区.我怎样才能做到这一点?
我使用TelephonyManager:getNetworkCountryIso()方法来获取移动国家代码(MCC).但是文档说"只有当用户注册到网络时.结果在CDMA网络上可能不可靠"而且,当我尝试这个时,
所有gsm的地方.我无法弄清楚为什么我不能获得第四个案件的mcc?
此外,谷歌如何识别设备的国家/地区以过滤市场中的应用程序?
任何的想法?
编辑:我在戴尔Venue(2.2)尝试使用wifi,没有SIM卡:我没有得到MCC
android mobile-country-code telephonymanager android-market-filtering
我需要从国家名称(如 IN、US、SG ... 使用区域设置或 Android 设备中的当前位置)获取国家代码,如 +91、+1、+65...
即假设如果设备在印度,则返回 +91,如果设备在美国,则返回 +1,如果设备在新加坡,则返回 +65
我尝试了很多方法,但我无法得到正确的解决方案。
public static Country getCountryFromLocation(Context cxt, List<Country> countryList, Location location, int maxAddress) {
if (location == null || countryList == null || countryList.isEmpty()) {
Log.d("ooo", "location == null || countryList == null || countryList.isEmpty()");
return null;
}
double longitude = location.getLongitude();
double latitude = location.getLatitude();
Geocoder coder = new Geocoder(cxt);
try {
List<Address> addressList = coder.getFromLocation(latitude, longitude, maxAddress);
for (Address address : addressList) {
String curCountryCode = address.getCountryCode();
Log.d("ooo", "address " + address.toString());
if (TextUtils.isEmpty(curCountryCode)) {
continue;
}
for (Country country …
Run Code Online (Sandbox Code Playgroud) android google-maps country-codes geolocation mobile-country-code
我试图让mcc
和mnc
一个后SIM LOADED
状态,以检查SIM卡的确发生了变化没有READ PHONE STATE
权限,以禁用某些网络应用程序的请求,并在一些国家,用户不想要的.
由于getSimOperator()
可能会根据当前的运营商进行更改(例如,当用户正在漫游时),我决定使用getNetworkOperator()
.
虽然这种方法可以返回null
即使SIM
IS LOADED
,可能会返回不同的结果,如莱卡移动通讯卡仅限GSM连接是给我mnc = 01
,当我把SIM卡取出并再次把它放在它给了我mnc = 04
.
有人知道为什么mnc会给出不同的结果getNetworkOperator()
吗?哪种方法更好,getNetworkOperator()
或者getSimOperator()
对于这种情况?
此外,我不能使用,getResources().getConfiguration().mcc
因为它给出一个int数字可能会删除0
之前,例如给出4
而不是04
.
这是我检查SIM状态更改的代码:
@Override
public void onReceive(final Context context, Intent intent) {
if (intent != null) {
Bundle extras = intent.getExtras();
if (extras != null) {
String ss = extras.getString(EXTRAS_SIM_STATUS);
if (ss != null …
Run Code Online (Sandbox Code Playgroud) 我正在开发 flutter 应用程序,我有一个文本小部件,我想在其中根据用户的位置显示用户当前的国家/地区代码,而无需任何下拉菜单。我使用区域设置获得诸如“IN”、“US”之类的值,但我不想要它,我需要数字国家代码,如+91(印度)、+1(美国)等。请任何人帮助我。
从下面的帖子中我试图检测iPhone 中的SIM 卡
我尝试了您提供的相同代码,但它总是返回我(空)。我已添加core telephony framework
并导入CTCarrier.h
文件。我还有什么需要做的吗?
谢谢
我从数据库中获取手机号码我有更多的1000手机号码,我的数据库看起来像这样
mobilenumber
971525478965
919844005522
45712345678
Run Code Online (Sandbox Code Playgroud)
我想通过数据库中的每个数字,并countrycode
从手机号码显示countrycode
和使用PHP的国家
比如这样
countrycode 971 country UAE
countrycode 91 country India
countrycode 45 country Denmark
Run Code Online (Sandbox Code Playgroud)
任何人有任何建议请指导我如何做到这一点.
我试过这样,但想从数据库中检查多个移动数据
<?php
$number = "971527139011";
$countrys = array(
'1' => 'us',
'2' => 'uk',
'3' => 'de',
'44' => 'fi',
'123' => 'no',
'971' =>'uae',
'91' =>'india',
'92' =>'pakistan'
);
$i = 4;
$country = "";
while ($i > 0) {
if (isset($countrys[substr($number, 0, $i)])) {
$country = $countrys[substr($number, 0, $i)];
break;
} else {
$i--; …
Run Code Online (Sandbox Code Playgroud) 我的应用程序如何以编程方式获取设备的国家/地区代码?
当我收到传入的短信时,发件人号码始终包含国家/地区代码.但是,对于我的应用程序,我让用户手动输入他/她的电话号码,但我还需要知道国家/地区代码.
无论如何都要获取设备的国家代码和/或电话号码?
android ×5
dart ×1
flutter ×1
geolocation ×1
google-maps ×1
gsm ×1
ios ×1
locale ×1
phone-number ×1
php ×1