开发者

Getting city and country information on Android

开发者 https://www.devze.com 2023-03-07 01:29 出处:网络
I want to get a users city and country information WITHOUT GPS enabled? Is there a way 开发者_JS百科to obtain this data from their carriers? Use LocationManager to get the location. You need to add pe

I want to get a users city and country information WITHOUT GPS enabled? Is there a way 开发者_JS百科to obtain this data from their carriers?


Use LocationManager to get the location. You need to add permission for ACCESS_COARSE_LOCATION in the manifest file


TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = tm.getNetworkCountryIso();
0

精彩评论

暂无评论...
验证码 换一张
取 消