Example usage for android.location CountryDetector detectCountry

List of usage examples for android.location CountryDetector detectCountry

Introduction

In this page you can find the example usage for android.location CountryDetector detectCountry.

Prototype

@UnsupportedAppUsage
public Country detectCountry() 

Source Link

Document

Start detecting the country that the user is in.

Usage

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

public static String detectCountry() {
    try {/*  ww w.jav a  2  s  . co  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;
}