DefaultCountryDetector

fun DefaultCountryDetector(context: Context, fallbackIso2Code: String? = DefaultCountryDetector.DEFAULT_FALLBACK_ISO2_CODE): DefaultCountryDetector(source)

Creates a DefaultCountryDetector reading SIM → network → configuration locale → default locale.

simCountryIso and networkCountryIso are permission-free reads, so no permission is needed.

Parameters

context

Any context; only getSystemService and getResources are used, so an application context is fine and no leak is possible.

fallbackIso2Code

Country reported with CountryDetectionSource.Default when every signal is blank. Pass null to report CountryDetectionResult.Unavailable instead of guessing — the right choice when a wrong default is worse than no default.

fun DefaultCountryDetector(fallbackIso2Code: String? = DefaultCountryDetector.DEFAULT_FALLBACK_ISO2_CODE): DefaultCountryDetector(source)

Creates a DefaultCountryDetector reading the user's Region setting.

iOS exposes no usable SIM or network country: CoreTelephony's carrier properties have returned placeholder values since iOS 16. The Region setting (Settings › General › Language & Region) is an explicit user choice, which makes it a better signal than a language-derived locale.

Parameters

fallbackIso2Code

Country reported with CountryDetectionSource.Default when no signal resolves. Pass null to report CountryDetectionResult.Unavailable instead of guessing.