<s>[INST] How can implement network country detection on android? I am using Kotlin. [/INST] There are multiple implementation for detecting the country on android using kotlin. But by far the most simple way to do it is with this line of code:

String country = context.getResources().getConfiguration().locale.getCountry();</s>\ <s>[INST] What versions of Android does this work for? [/INST] On Android 10 or newer you can use the following Kotlin code
```
val fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
fusedLocationClient.lastLocation
    .addOnSuccessListener { location: Location? ->
        val geocoder = Geocoder(this, Locale.getDefault())
        val addresses = geocoder.getFromLocation(location!!.latitude, location.longitude, 1)
        val countryCode = addresses[0].countryCode
    }
```</s>