當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。