当前位置: 首页>>代码示例>>Java>>正文


Java Geocoder.isPresent方法代码示例

本文整理汇总了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);
}
 
开发者ID:T-MAPY,项目名称:T-Rex,代码行数:29,代码来源:BackgroundLocationService.java

示例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));
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:23,代码来源:LocationGeofenceEditorActivity.java

示例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();
}
 
开发者ID:SchibstedSpain,项目名称:Leku,代码行数:12,代码来源:LocationPickerActivity.java

示例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");
    }
}
 
开发者ID:simplesoft-duongdt3,项目名称:Android-App-Template,代码行数:13,代码来源:AndroidGeocodingProvider.java

示例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();
        }
    }
 
开发者ID:yeloapp,项目名称:yelo-android,代码行数:39,代码来源:HomeScreenFragment.java

示例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);
    }
}
 
开发者ID:tausiq,项目名称:DroidPlate,代码行数:10,代码来源:LocationHelper.java

示例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;
}
 
开发者ID:M66B,项目名称:FineGeotag,代码行数:15,代码来源:LocationService.java

示例9: isGeocoderPresent

import android.location.Geocoder; //导入方法依赖的package包/类
/**
 * Returns true if a Geocoder is implemented on the device.
 */
public static boolean isGeocoderPresent() {
    return Geocoder.isPresent();
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:7,代码来源:GeocodingTask.java

示例10: isGeoCoderPresent

import android.location.Geocoder; //导入方法依赖的package包/类
@Override
public boolean isGeoCoderPresent() {
  return Geocoder.isPresent();
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:5,代码来源:Api9Adapter.java

示例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();
}
 
开发者ID:jp1017,项目名称:TheSceneryAlong,代码行数:9,代码来源:ReverseGeocodingUtil.java

示例12: isPresent

import android.location.Geocoder; //导入方法依赖的package包/类
public static boolean isPresent() {
    return Geocoder.isPresent();
}
 
开发者ID:M66B,项目名称:BackPackTrackII,代码行数:4,代码来源:GeocoderEx.java

示例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();
        }
    }
 
开发者ID:yeloapp,项目名称:yelo-android,代码行数:43,代码来源:PostOnWallActivity.java


注:本文中的android.location.Geocoder.isPresent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。