本文整理汇总了Java中android.location.Geocoder.isPresent方法的典型用法代码示例。如果您正苦于以下问题:Java Geocoder.isPresent方法的具体用法?Java Geocoder.isPresent怎么用?Java Geocoder.isPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.location.Geocoder
的用法示例。
在下文中一共展示了Geocoder.isPresent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processLocation
import android.location.Geocoder; //导入方法依赖的package包/类
private WeatherLocation processLocation(Location location) {
if (location != null) {
PowerManager powerManager = (PowerManager) mApplicationContext.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MobileWeatherProcessLocation");
try {
wakeLock.acquire();
WeatherLocation loc = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Geocoder.isPresent()) {
loc = reverseGeocode(location);
}
else {
loc = new WeatherLocation();
GPSLocation gpsLoc = new GPSLocation();
gpsLoc.latitude = String.valueOf(location.getLatitude());
gpsLoc.longitude = String.valueOf(location.getLongitude());
loc.gpsLocation = gpsLoc;
}
return loc;
} finally {
wakeLock.release();
}
}
return null;
}
开发者ID:smartdevicelink,项目名称:sdl_mobileweather_tutorial_android,代码行数:27,代码来源:WeatherLocationServices.java
示例2: acceptLocation
import android.location.Geocoder; //导入方法依赖的package包/类
/**
* Process accepted location
*
* @param location
*/
private void acceptLocation(Location location) {
LocationWrapper loc = new LocationWrapper();
loc.setLocation(location);
if (mFirstLocation == null)
mFirstLocation = loc;
mLastAcceptedLocation = loc; //location is accepted even if it is not possible to send
if (mGeocoding && Geocoder.isPresent()) {
new GeocodingTask().execute(location);
}
if (Const.LOG_ENHANCED)
Log.d(TAG, ((mSendActivity && mActivity != null) ? mActivity + ": " : "New position at: ") + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(loc.getLocation().getTime()) + " (" + loc.getLocation().getLatitude() + ", " + loc.getLocation().getLongitude() + ")");
//add location to list of accepted
mAcceptedLocations.add(loc);
sendPositionsToServer();
storePositionToPrefs(loc);
sendAcceptedLocationBroadcast(loc);
}
示例3: refreshActivity
import android.location.Geocoder; //导入方法依赖的package包/类
public void refreshActivity(boolean setMapCamera) {
//Log.d("LocationGeofenceEditorActivity.refreshActivity", "xxx");
getLastLocation();
boolean enableAddressButton = false;
if (mLocation != null) {
//Log.d("LocationGeofenceEditorActivity.refreshActivity", "latitude=" + String.valueOf(mLocation.getLatitude()));
//Log.d("LocationGeofenceEditorActivity.refreshActivity", "longitude=" + String.valueOf(mLocation.getLongitude()));
// Determine whether a Geocoder is available.
if (Geocoder.isPresent()) {
startIntentService(false);
enableAddressButton = true;
}
}
if (addressButton.isEnabled())
GlobalGUIRoutines.setImageButtonEnabled(enableAddressButton, addressButton, R.drawable.ic_action_location_address, getApplicationContext());
String name = geofenceNameEditText.getText().toString();
updateEditedMarker(setMapCamera);
okButton.setEnabled((!name.isEmpty()) && (mLocation != null));
}
示例4: didGetLastLocation
import android.location.Geocoder; //导入方法依赖的package包/类
@Override
public void didGetLastLocation() {
if (currentLocation != null) {
if (!Geocoder.isPresent()) {
Toast.makeText(this, R.string.leku_no_geocoder_available, Toast.LENGTH_LONG).show();
return;
}
setUpMapIfNeeded();
}
setUpDefaultMapLocation();
}
示例5: AndroidGeocodingProvider
import android.location.Geocoder; //导入方法依赖的package包/类
public AndroidGeocodingProvider(Locale locale) {
if (locale == null) {
// This should be super weird
throw new RuntimeException("Locale is null");
}
this.locale = locale;
fromNameList = new HashMap<>();
fromLocationList = new HashMap<>();
if (!Geocoder.isPresent()) {
throw new RuntimeException("Android Geocoder not present. Please check if Geocoder.isPresent() before invoking the search");
}
}
示例6: getLatLongFromAddress
import android.location.Geocoder; //导入方法依赖的package包/类
private void getLatLongFromAddress(double latitude, double longitude) {
Geocoder geoCoder = new Geocoder(getActivity(), Locale.getDefault());
if (Geocoder.isPresent()) {
try {
List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);
if (addresses.size() > 0) {
double lat = addresses.get(0).getLatitude();
double lng = addresses.get(0).getLongitude();
String locality = addresses.get(0).getSubLocality();
String city = addresses.get(0).getAddressLine(2);
if (TextUtils.isEmpty(city)) {
fillAddressDetails();
}
else {
SharedPreferenceHelper.set(R.string.pref_city, addresses.get(0).getAddressLine(2).split(",")[0].trim());
((AbstractYeloActivity) getActivity()).setLocationTitleWithRedDot(addresses.get(0).getAddressLine(2).split(",")[0].trim(), mToolbar, mLocationTitleText);
}
Logger.d(TAG, lat + " " + lng);
} else {
fillAddressDetails();
}
} catch (Exception e) {
fillAddressDetails();
}
}
else {
fillAddressDetails();
}
}
示例7: getGeoAddress
import android.location.Geocoder; //导入方法依赖的package包/类
public void getGeoAddress(Location location) {
if (mGoogleApiClient != null && location != null) {
if (!Geocoder.isPresent()) {
return;
}
mLastKnownLocation = location;
startIntentService(location);
}
}
示例8: reverseGeocode
import android.location.Geocoder; //导入方法依赖的package包/类
private static List<String> reverseGeocode(Location location, Context context) {
List<String> listLine = new ArrayList<>();
if (location != null && Geocoder.isPresent())
try {
Geocoder geocoder = new Geocoder(context);
List<Address> listPlace = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
if (listPlace != null && listPlace.size() > 0) {
for (int l = 0; l < listPlace.get(0).getMaxAddressLineIndex(); l++)
listLine.add(listPlace.get(0).getAddressLine(l));
}
} catch (IOException ignored) {
}
return listLine;
}
示例9: isGeocoderPresent
import android.location.Geocoder; //导入方法依赖的package包/类
/**
* Returns true if a Geocoder is implemented on the device.
*/
public static boolean isGeocoderPresent() {
return Geocoder.isPresent();
}
示例10: isGeoCoderPresent
import android.location.Geocoder; //导入方法依赖的package包/类
@Override
public boolean isGeoCoderPresent() {
return Geocoder.isPresent();
}
示例11: isReverseGeocodePresent
import android.location.Geocoder; //导入方法依赖的package包/类
/**
* @description: 是否支持反向地理编码
* @author: chenshiqiang E-mail:[email protected]
*/
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static boolean isReverseGeocodePresent(){
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Geocoder.isPresent();
}
示例12: isPresent
import android.location.Geocoder; //导入方法依赖的package包/类
public static boolean isPresent() {
return Geocoder.isPresent();
}
示例13: getLatLongFromAddress
import android.location.Geocoder; //导入方法依赖的package包/类
private void getLatLongFromAddress(double latitude, double longitude) {
Geocoder geoCoder = new Geocoder(this, Locale.getDefault());
if (Geocoder.isPresent()) {
try {
List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);
if (addresses.size() > 0) {
double lat = addresses.get(0).getLatitude();
double lng = addresses.get(0).getLongitude();
String locality = addresses.get(0).getSubLocality();
mCityName = addresses.get(0).getAddressLine(2);
mStateName = addresses.get(0).getAdminArea();
mCountryName = addresses.get(0).getCountryName();
mAddressName = addresses.get(0).getSubLocality();
mLatitude = addresses.get(0).getLatitude() + "";
mLongitude = addresses.get(0).getLongitude() + "";
if(TextUtils.isEmpty(locality)) {
fillAddressDetails();
}
else {
mPlaceName.setText(locality);
}
Logger.d(TAG, lat + " " + lng);
} else {
fillAddressDetails();
}
} catch (Exception e) {
e.printStackTrace();
fillAddressDetails();
}
}
else {
fillAddressDetails();
}
}