Android LocationManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android LocationManager class.

This code example shows how to use the following methods:removeUpdates
		return (cLoc != null);
	} 
 
	public void stop() 
	{ 
		mLocMan.removeUpdates(this);
	} 
	 
} 
9
CodeRank
This code example shows how to use the following methods:getLastKnownLocation
		cLoc = mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
	} 
	 
	public Location getLocation()
	{ 
		cLoc = mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
		return cLoc;
	} 
 
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub 
		Log.d(LOG_TAG, "The provider " + provider + " is disabled");
	} 
 
 
	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub 
		Log.d(LOG_TAG, "The provider "+ provider + " is enabled");
	} 
 
10
CodeRank
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled, requestLocationUpdates
	 
	 
	@Override 
	public void async(Context context){
		lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);		
		gpsEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
		networkEnabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
		work(); 
	} 
	 
	public LocationAjaxCallback timeout(long timeout){
		this.timeout = timeout;
		return this;
	} 
	 
	public LocationAjaxCallback accuracy(float accuracy){
		this.accuracy = accuracy;
		return this;
	} 
	 

9
CodeRank
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled, requestLocationUpdates
	        locationManager = (LocationManager) myAndroidContext
	                .getSystemService(Context.LOCATION_SERVICE);
 
	        // getting GPS status 
	        isGPSEnabled = locationManager
	                .isProviderEnabled(LocationManager.GPS_PROVIDER);
 
	        // getting network status 
	        isNetworkEnabled = locationManager
	                .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
 
	        if (!isGPSEnabled && !isNetworkEnabled) {
	            // no network provider is enabled 
	        } else { 
	            this.canGetLocation = true;
	            if (isNetworkEnabled) {
	                locationManager.requestLocationUpdates(
	                        LocationManager.NETWORK_PROVIDER,
	                        MIN_TIME_BW_UPDATES,
	                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

10
CodeRank
This code example shows how to use the following methods:getBestProvider, getLastKnownLocation
-66
CodeRank
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled, requestLocationUpdates
     * @param myLocationFoundListener the callback 
     */ 
    public void requestLocationUpdates(MyLocationFoundListener myLocationFoundListener) {
        mMyLocationFoundListener = myLocationFoundListener;
 
        if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            mGpsLocationListener = new MyLocationListener();
            mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                    0, 0, mGpsLocationListener);
        } 
 
        if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
            mNetworkLocationListener = new MyLocationListener();
            mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
                    0, 0, mNetworkLocationListener);
        } 
 
        if (mNetworkLocationListener != null || mGpsLocationListener != null) {
            mLocationRequestTimeOut.start();
        } else { 

8
CodeRank
This code example shows how to use the following methods:removeUpdates
   
  @Override 
  public void onPause() { 
    super.onPause(); 
     
    mgr.removeUpdates(onLocationChange);
  } 
   
  @Override 
  public void onDestroy() { 
    super.onDestroy(); 
     
    client.getConnectionManager().shutdown();
  } 
   
  private void updateForecast(Location loc) {
    String url=String.format(format, loc.getLatitude(),
                             loc.getLongitude());
    HttpGet getMethod=new HttpGet(url);
     
8
CodeRank
This code example shows how to use the following methods:isProviderEnabled
	} 
	 
	public boolean isGpsLocationServiceActive() { 
		boolean gps_enabled = false;
		try { 
			gps_enabled = androidLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
		} catch (Exception ex) {
		} 
		return gps_enabled;
	} 
	 
	public boolean isNetworkLocationServiceActive() { 
		boolean network_enabled = false;
		try { 
			network_enabled = androidLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
		} catch (Exception ex) {
		} 
		return network_enabled;
	} 
 
7
CodeRank
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled
		mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
	} 
	 
	private boolean isGpsLocationProviderEnabled() { 
		try { 
        	return mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        } catch (Exception e) {
        	DebugLog.d(TAG, e.getMessage());
        } 
		 
		return false; 
	} 
	 
	private boolean isNetworkLocationProviderEnabled() { 
		try { 
        	return mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        } catch (Exception e) {
        	DebugLog.d(TAG, e.getMessage());
        } 
		 

6
CodeRank
This code example shows how to use the following methods:requestLocationUpdates
    super.onCreate(); 
 
    executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
 
    mgr=(LocationManager)getSystemService(LOCATION_SERVICE);
    mgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    mgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                               this);
  } 
 
  @Override 
  public void onDestroy() { 
    mgr.removeUpdates(this);
    executor.shutdown();
 
    super.onDestroy(); 
  } 
 
  @Override 
  public IBinder onBind(Intent arg0) {
8
CodeRank

Related Android LocationManager Questions & Answers:

Other Android LocationManager Examples

13:	  private TextView latituteField;
14:	  private TextView longitudeField;
15:	  private LocationManager locationManager;
16:	  private String provider;
17:	
-
25:	
26:	    // Get the location manager
27:	    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
28:	    // Define the criteria how to select the locatioin provider -> use
29:	    // default

Read More

1:			try {
2:				locationManager = (LocationManager) mContext
3:						.getSystemService(LOCATION_SERVICE);
4:

Read More

37:	
38:		// Declaring a Location Manager
39:		protected LocationManager locationManager;
40:	
41:		public GPSTracker(Context context) {
-
46:		public Location getLocation() {
47:			try {
48:				locationManager = (LocationManager) mContext
49:						.getSystemService(LOCATION_SERVICE);
50:

Read More

37:	
38:		// Declaring a Location Manager
39:		protected LocationManager locationManager;
40:	
41:		public GPSTracker(Context context) {
-
46:		public Location getLocation() {
47:			try {
48:				locationManager = (LocationManager) mContext
49:						.getSystemService(LOCATION_SERVICE);
50:

Read More

See Code Examples for Android LocationManager Methods: