Location toString - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:setProvider, toString
				} 
			} 
			 
			if (intent.hasExtra(LocationManager.KEY_PROXIMITY_ENTERING)){ 
				if (intent.getBooleanExtra(LocationManager.KEY_PROXIMITY_ENTERING, true)==true) { 
					location.setProvider("prx_enter"); 
				} else { 
					location.setProvider("prx_exit"); 
				} 
			} 
			addLocationToDB(location); 
		} 
	}; 
 
	@Override 
	public int onStartCommand(Intent intent, int flags, int startId) {
		Log.i(TAG, "onStartCommand()");
		super.onStartCommand(intent, flags, startId);
		// We want this service to continue running until it is explicitly 
		// stopped, so return sticky. 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getLatitude, getLongitude, getProvider, getTime
     *  
     * @param location 
     * @return rowId or -1 if failed 
     */ 
    public long addLocation(Location location) {
    	Log.i(TAG, "Writing new location:"+location.toString());
    	ContentValues contentValues = new ContentValues();
        contentValues.put(KEY_NAME, location.getProvider());
        contentValues.put(KEY_LATITUDE, location.getLatitude());
        contentValues.put(KEY_LONGITUDE, location.getLongitude());
        contentValues.put(KEY_ACCURACY, location.getAccuracy());
        contentValues.put(KEY_TIME, location.getTime());
 
        return mDb.insert(DATABASE_TABLE, null, contentValues);
    } 
 
    public int clearDatabase() { 
    	Log.i(TAG, "clearDatabase()");
    	return mDb.delete(DATABASE_TABLE, null, null);
    } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getProvider, getTime, toString
				 * mAltitude=0.0, mHasSpeed=false, mSpeed=0.0, 
				 * mHasBearing=false, mBearing=0.0, mHasAccuracy=true, 
				 * mAccuracy=55.0, mExtras=Bundle[mParcelledData.dataSize=148]] 
				 */ 
				// The location is better 
				Log.i(TAG, "Got a better location - " + location.toString()); 
			} 
		} 
 
		public void onStatusChanged(String provider, int status, Bundle extras) { 
			Log.i(TAG, "Provider status changed - Provider: " + provider 
					+ " - Status: " + status); 
		} 
 
		public void onProviderEnabled(String provider) { 
			Log.i(TAG, provider + " Provider enabled"); 
		} 
 
		public void onProviderDisabled(String provider) { 
			Log.i(TAG, provider + " Provider enabled"); 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getTime, hasAccuracy, toString
            onBestLocationChanged(location);
        } 
    } 
 
    public boolean isAccurateEnough(Location location) {
        if (location != null && location.hasAccuracy()
                && location.getAccuracy() <= REQUESTED_FIRST_SEARCH_ACCURACY_IN_METERS) {
            long locationUpdateDelta = new Date().getTime() - location.getTime();
            if (locationUpdateDelta < REQUESTED_FIRST_SEARCH_MAX_DELTA_THRESHOLD) {
                if (DEBUG) Log.d(TAG, "Location is accurate: " + location.toString());
                return true; 
            } 
        } 
        if (DEBUG) Log.d(TAG, "Location is not accurate: " + String.valueOf(location));
        return false; 
    } 
 
    public void register(LocationManager locationManager, boolean gps) {
        if (DEBUG) Log.d(TAG, "Registering this location listener: " + this.toString());
        long updateMinTime = SLOW_LOCATION_UPDATE_MIN_TIME;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getLatitude, getLongitude, toString
	*/ 
	public static void out(Location message)
	{ 
		try 
		{ 
			out(message.toString());
			out("\t Latitude: " + message.getLatitude());
			out("\t Longitude: " + message.getLongitude());
			out("\t Accuracy: " + message.getAccuracy());
		} 
		catch (Exception e)
		{ 
			e.printStackTrace();
		} 
	} 
 
	/** 
	* Outputs a message to the debug console 
	* @param message The message to output 
	*/ 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setLatitude, setLongitude, setTime, toString
		} 
		 
		private void setupLocation(double lat, double lng) {
			Log.v(TAG, String.format("setupLocation() called: lat=[%f] lng=[%f]", lat, lng));
			// translate to actual GPS location 
			Location location = new Location(GPS_MOCK_PROVIDER);
			location.setLatitude(lat);
			location.setLongitude(lng);
			// location.setAltitude(altitude); 
			location.setTime(System.currentTimeMillis());
 
			// show debug message in log 
			Log.d(TAG, location.toString());
 
			// provide the new location 
			LocationManager mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
			mLocationManager.setTestProviderLocation(GPS_MOCK_PROVIDER, location);
		} 
		 
		private double getStep() { 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:bearingTo, distanceTo, getAltitude, getLatitude, getLongitude
 
	} 
 
	private void calculateDestinationAndBearing() { 
		if (null != mDestination && null != mMapCenter) {
			final int distance = (int) mMapCenter.distanceTo(mDestination);
			mRadarView.setBearing(mMapCenter.bearingTo(mDestination));
			mTextViewDistance.setText(Util.buildDistanceString(distance));
			if (mLastLocation != null) {
				mTextViewSpeed.setText(Util.buildSpeedString(mLastLocation.getSpeed()));
			} 
		} 
	} 
 
	/********************************************* 
	 * GPS Callbacks 
	 *********************************************/ 
 
	@Override 
	public void onLocationChanged(final Location location) {

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLatitude, getLongitude, toString
	} 
	private void logAddressLine(int index, String line){
		Log.d(getTag(), "AddressLine[" + String.valueOf(index) + "]=" + line);
	} 
	private List<Address> getAddressesFromLocation(Location location){
		double lat = location.getLatitude();
		double lng = location.getLongitude();
		List<Address> list;
		 
		try { 
			list = getAddressesFromLatAndLng(lat, lng);
		} catch (IOException e) {
			e.printStackTrace();
			logIOException(location);
			list = new ArrayList<Address>();
		} 
		return list;
	} 
	private List<Address> getAddressesFromLatAndLng(double lat, double lng) throws IOException{
		List<Address> list;

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAccuracy, getAltitude, getBearing, getLatitude, getLongitude
This code example shows how to use the following methods:getLatitude, getLongitude, toString
 
    // ����λ����Ϣ 
    private void updateLocation(Location location) {
            if (location != null) {
            	try{ 
            		ToLocation tl = new ToLocation(location);
					String pos = tl.getLocation();
            		result = "��λ������Ϣ���£�" + location.toString() + "\n\t���о��ȣ�" + location.getLongitude() + "\n\t����γ�ȣ�"
                    + location.getLatitude()+ pos;
                } catch (Exception e) {
				// TODO Auto-generated catch block 
			    	e.printStackTrace();
			    } 
            	 
            	 
            } else { 
            	    result = "û�л�ȡ����λ����Location";
                    Log.i("gps", "û�л�ȡ����λ����Location");
            } 
    } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Location toString Questions & Answers:

toString Method Overview
Returns a string containing a concise, human-readable description of this object.
See Code Examples for other Android Location Methods: