private boolean sameCountry(Country country1, Country country2) {
   return country1 == null && country2 == null
       || country1 != null
           && country2 != null
           && country1.getCountryIso().equalsIgnoreCase(country2.getCountryIso())
           && country1.getSource() == country2.getSource();
 }
Ejemplo n.º 2
0
 /** @return The ISO 3166-1 two letters country code of the country the user is in. */
 private static String getCurrentCountryIso(Context context, Locale locale) {
   String countryIso = null;
   CountryDetector detector = (CountryDetector) context.getSystemService(Context.COUNTRY_DETECTOR);
   if (detector != null) {
     Country country = detector.detectCountry();
     if (country != null) {
       countryIso = country.getCountryIso();
     } else {
       Rlog.e(TAG, "CountryDetector.detectCountry() returned null.");
     }
   }
   if (countryIso == null) {
     countryIso = locale.getCountry();
     Rlog.w(TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso);
   }
   return countryIso;
 }