Address setLongitude - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Address setLongitude method.

This code example shows how to use the following methods:setLatitude, setLongitude
        } 
        if (returnNoResults) {
            return new ArrayList<Address>();
        } else { 
            Address address = makeAddress();
            address.setLatitude(simulatedLatitude);
            address.setLongitude(simulatedLongitude);
            return oneElementList(address);
        } 
    } 
 
    private Address makeAddress() {
        Address address = new Address(Locale.getDefault());
        shadowOf(address).setSimulatedHasLatLong(hasLatitude, hasLongitude);
        return address;
    } 
 
    /** 
     * Sets up a simulated response for {@link #getFromLocation(double, double, int)} 
     * 
8
CodeRank
This code example shows how to use the following methods:setLatitude, setLongitude
    public List<Address> getFromLocationName(String locationName, int maxResults) throws IOException {
        this.lastLocationName = locationName;
        if (shouldSimulateGeocodeException) {
            throw new IOException("Simulated geocode exception");
        } 
        Address address = new Address(Locale.getDefault());
        address.setLatitude(simulatedLatitude);
        address.setLongitude(simulatedLongitude);
        return oneElementList(address);
    } 
 
    /** 
     * Sets up a simulated response for {@link #getFromLocation(double, double, int)} 
     * 
     * @param address     the address for the response 
     * @param city        the city for the response 
     * @param state       the state for the response 
     * @param zip         the zip code for the response 
     * @param countryCode the country code for the response 
     */ 
7
CodeRank
This code example shows how to use the following methods:setLatitude, setLocality, setLongitude
    private static final int MAX_ADDRESS_RESULTS = 5;
    private static final String OPPORTUNITY_LOCATION_NAME = "Opportunity GeoLocation";
 
    private static Address getDefaultAddress(boolean emulateLocation) {
        if (emulateLocation) {
            Address address = new Address(Locale.getDefault());
            address.setLocality("Zaventem");
            address.setLatitude(50.888829);
            address.setLongitude(4.45855);
            return address;
        } 
        return null; 
    } 
 
    public static Address getAddressFromLocation(Location location, Context context) {
        Address tempAddress = null;
        if (location != null) {
            try { 
                Geocoder geocoder = new Geocoder(context);
 
6
CodeRank
This code example shows how to use the following methods:setExtras, setFeatureName, setLatitude, setLongitude
	 * Builds an {@link Address} based on this Google Place. 
	 *  
	 * @return	an {@link Address} 
	 */ 
	public Address getAddress() {
		Address address = new Address(Locale.getDefault());
		address.setFeatureName(name);
		address.setLatitude(latitude);
		address.setLongitude(longitude);
 
		Bundle extras = new Bundle();
		extras.putString("formatted_address", formattedAddress);
		address.setExtras(extras);
 
		return address;
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:setCountryCode, setCountryName, setLatitude, setLongitude
This code example shows how to use the following methods:setExtras, setFeatureName, setLatitude, setLongitude
  public void setUp() throws Exception { 
		super.setUp(); 
	} 
	 
	public void testAddressToJson() { 
		Address dummy = new Address(Locale.getDefault());
		dummy.setFeatureName("Dummy Address");
		dummy.setLatitude(30.12345);
		dummy.setLongitude(-97.12345);
		 
		Bundle extras = new Bundle();
		extras.putString("formatted_address", "Formatted, pretty Dummy Address");
		dummy.setExtras(extras);
		 
		StringWriter sWriter = new StringWriter();
		JsonWriter jWriter = new JsonWriter(sWriter);
		Util.writeAddress(jWriter, dummy);
		String json = sWriter.toString();
		try { 
			sWriter.close();
6
CodeRank
This code example shows how to use the following methods:setAdminArea, setFeatureName, setLatitude, setLocality, setLongitude
         * sub admin area 
         * locality 
         * thoroughfare 
         * feature name 
         */ 
        final Address a = new Address(Locale.getDefault());
 
        a.setLongitude(in.readDouble());
        a.setLatitude(in.readDouble());
        final String admin = in.readUTF();
        final String subAdmin = in.readUTF();
        final String locality = in.readUTF();
        final String thoroughfare = in.readUTF();
        final String feature = in.readUTF();
 
        if (admin.length() > 0)
            a.setAdminArea(admin);
        if (subAdmin.length() > 0)
            a.setSubAdminArea(subAdmin);
        if (locality.length() > 0)

5
CodeRank
This code example shows how to use the following methods:setLatitude, setLongitude
			double latitude = location.getLatitude();
			double longitude = location.getLongitude();
			 
			// Generate a default Address instance in case the Geocoder 
			// fails to get any results. 
			bestMatch = new Address(Locale.ENGLISH);
			bestMatch.setLatitude(latitude);
			bestMatch.setLongitude(longitude);
			 
			Geocoder geocoder = new Geocoder(this._context);
			List<Address> matches = 
				geocoder.getFromLocation(latitude, longitude, 1);
			if (matches != null && ! matches.isEmpty()) {
				bestMatch = matches.get(0);
				bestMatch.setLatitude(latitude);
				bestMatch.setLongitude(longitude);
			} 
		} catch (IndexOutOfBoundsException e) {
			Log.e(TAG, ERROR_FAILED_TO_GET_LOCATION_PARAM, e);
			this.setException(e);
5
CodeRank
This code example shows how to use the following methods:setAddressLine, setAdminArea, setExtras, setFeatureName, setLatitude
				Log.e(TAG, "Geocoder API response status not ok -- status=" + status);
				throw new RoutyException("There was a problem understanding an address."); 
			} else {  
				// TODO status is ok - parse the XML into an Address object 
				int lineNumber = 0;
				Address result = new Address(Locale.getDefault());
				 
				expr = "/GeocodeResponse/result";
				NodeList results = (NodeList) xpath.evaluate(expr, root, XPathConstants.NODESET);
				if (results.getLength() == 0) {
					return null; 
				} 
				 
				// GET THE PLACE NAME (ESTABLISHMENT) IF THERE IS ONE (EX. "UNIVERSITY OF TEXAS") 
				expr = "/GeocodeResponse/result[1]/address_component[type=\"establishment\"]/long_name";
				String establishment = (String) xpath.evaluate(expr, root, XPathConstants.STRING);
				result.setFeatureName(establishment);
//				Log.v(TAG, "establishment=" + establishment); 
				 
				// GET THE STREET NUMBER AND NAME 

5
CodeRank
This code example shows how to use the following methods:setLatitude, setLongitude
				return; 
			} 
		} 
		if (lat != Double.NaN && lng != Double.NaN)
		{ 
			address.setLatitude(lat);
			address.setLongitude(lng);
		} 
	} 
	 
	/** 
	 * Interrupt the current geocoding query. 
	 */ 
	public synchronized void interruptQuery() { 
		mInterrupted = true;
	} 
 
	/** 
	 * Check if the query is interrupted 
	 * @return True if interrupted, false otherwise 
4
CodeRank

Related Address setLongitude Questions & Answers:

setLongitude Method Overview
Sets the longitude associated with this address.
See Code Examples for other Android Address Methods: