简体   繁体   English

Xamarin Forms - 如何获取设备的当前国家/地区

[英]Xamarin Forms - How to get the current country of the device

Is there a way to detect the current country of a mobile device?有没有办法检测移动设备的当前国家/地区? What I want for my application is that on sign up page, I require my user to enter the country code and the mobile number.我的应用程序想要的是在注册页面上,我要求我的用户输入国家代码和手机号码。 I want the country code to be filled up based on the current country the user is in by default on my picker control.我希望根据用户在我的选择器控件上默认所在的当前国家/地区填写国家/地区代码。

What about RegionInfo.CurrentRegion ? RegionInfo.CurrentRegion呢?
No platform code needed!无需平台代码!
Source 来源

对于 Xamarin Android:Java.Util.Locale.Default.ToString() 对于 Xamarin IOS:NSLocale.PreferredLanguages[1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM