/** * Gets the reverse geo coding string for a location. * * @param context the context * @param location the location */ private static String getReverseGeoCoding(Context context, Location location) { if (location == null || !ApiAdapterFactory.getApiAdapter().isGeoCoderPresent()) { return null; } Geocoder geocoder = new Geocoder(context); try { List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); if (addresses.size() > 0) { Address address = addresses.get(0); int lines = address.getMaxAddressLineIndex(); if (lines > 0) { return address.getAddressLine(0); } String featureName = address.getFeatureName(); if (featureName != null) { return featureName; } String thoroughfare = address.getThoroughfare(); if (thoroughfare != null) { return thoroughfare; } String locality = address.getLocality(); if (locality != null) { return locality; } } } catch (IOException e) { // Can safely ignore } return null; }
@SuppressLint("CommitPrefEdits") private static void setValue(Context context, String key, boolean value) { SharedPreferences sharedPreferences = context.getSharedPreferences(EULA_PREFERENCE_FILE, Context.MODE_PRIVATE); Editor editor = sharedPreferences.edit(); editor.putBoolean(key, value); ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor); }