Example usage for android.content Context COUNTRY_DETECTOR

List of usage examples for android.content Context COUNTRY_DETECTOR

Introduction

In this page you can find the example usage for android.content Context COUNTRY_DETECTOR.

Prototype

String COUNTRY_DETECTOR

To view the source code for android.content Context COUNTRY_DETECTOR.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.location.CountryDetector for detecting the country that the user is in.

Usage

From source file:com.android.mms.ui.MessageUtils.java

public static String detectCountry() {
    try {//w  ww  .  j  av  a 2s  . c o m
        CountryDetector detector = (CountryDetector) MmsApp.getApplication()
                .getSystemService(Context.COUNTRY_DETECTOR);
        final Country country = detector.detectCountry();
        if (country != null) {
            return country.getCountryIso();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}