List of usage examples for android.content Context LOCATION_SERVICE
String LOCATION_SERVICE
To view the source code for android.content Context LOCATION_SERVICE.
Click Source Link
From source file:com.oonusave.coupon.MyMapStore.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.store_map_view); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_title); mActivity = this; settings = getSharedPreferences(PREFS_NAME, 0); backButton = (ImageButton) findViewById(R.id.btnLeft); backButton.setVisibility(ImageButton.INVISIBLE); //backButton.setBackgroundResource(R.drawable.back_button); backButton.setBackgroundResource(ImageUtils.getBackIamge()); backButton.setOnClickListener(this); titleBarTextView = (TextView) findViewById(R.id.titleBarTextView); titleBarTextView.setText(TitleTextUtils.getMapViewTitleText()); ((ImageButton) findViewById(R.id.btnRight)).setVisibility(ImageButton.INVISIBLE); // mapView = (MapView) findViewById(R.id.mapview); // mapView.setBuiltInZoomControls(true); // mapOverlays = mapView.getOverlays(); // first overlay // drawable = getResources().getDrawable(R.drawable.map); // itemizedOverlay = new MyItemizedOverlay(drawable, mapView,true); ////from ww w. j a v a2 s . c om // // //mapOverlays.add(itemizedOverlay); // drawable2 = getResources().getDrawable(R.drawable.marker2); // itemizedOverlay2 = new MyItemizedOverlay(drawable2, mapView,false); // GeoPoint point2 = new GeoPoint((int)(Double.parseDouble(DataUtil.locationInfo.getLatitude()) * 1E6 ), (int)(Double.parseDouble(DataUtil.locationInfo.getLongitude()) * 1E6)); // OverlayItem overlayItem4 = new OverlayItem(point2, "Current Location", // ""); // itemizedOverlay2.addOverlay(overlayItem4); // mapOverlays.add(itemizedOverlay2); // // // final MapController mc = mapView.getController(); // mc.animateTo(point2); // mc.setZoom(9); // // DataUtil.mapScreen = true; // loadStores(); // Get the location manager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Define the criteria how to select the locatioin provider -> use // default Criteria criteria = new Criteria(); Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); // Initialize the location fields if (location != null) { System.out.println("Provider " + provider + " has been selected."); processOnLocationChanged(location); } else { // latituteField.setText("Location not available"); // longitudeField.setText("Location not available"); } }
From source file:com.jeremy.tripcord.main.TripcordFragment.java
private CameraUpdate getLastKnownLocation() { LocationManager lm = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_LOW); String provider = lm.getBestProvider(criteria, true); if (provider == null) { return null; }/*from www . j a v a 2 s . c o m*/ Location loc = lm.getLastKnownLocation(provider); if (loc != null) { return CameraUpdateFactory.newCameraPosition( CameraPosition.fromLatLngZoom(new LatLng(loc.getLatitude(), loc.getLongitude()), 14.0f)); } return null; }
From source file:com.radioactiveyak.location_best_practices.UI.PlaceActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Inflate the layout setContentView(R.layout.main);/*ww w . j a va2s . co m*/ // Get a handle to the Fragments placeListFragment = (PlaceListFragment) getSupportFragmentManager().findFragmentById(R.id.list_fragment); checkinFragment = (CheckinFragment) getSupportFragmentManager().findFragmentById(R.id.checkin_fragment); // Get references to the managers packageManager = getPackageManager(); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Get a reference to the Shared Preferences and a Shared Preference Editor. prefs = getSharedPreferences(PlacesConstants.SHARED_PREFERENCE_FILE, Context.MODE_PRIVATE); prefsEditor = prefs.edit(); // Instantiate a SharedPreferenceSaver class based on the available platform version. // This will be used to save shared preferences sharedPreferenceSaver = PlatformSpecificImplementationFactory.getSharedPreferenceSaver(this); // Save that we've been run once. prefsEditor.putBoolean(PlacesConstants.SP_KEY_RUN_ONCE, true); sharedPreferenceSaver.savePreferences(prefsEditor, false); // Specify the Criteria to use when requesting location updates while the application is Active criteria = new Criteria(); if (PlacesConstants.USE_GPS_WHEN_ACTIVITY_VISIBLE) criteria.setAccuracy(Criteria.ACCURACY_FINE); else criteria.setPowerRequirement(Criteria.POWER_LOW); // Setup the location update Pending Intents Intent activeIntent = new Intent(this, LocationChangedReceiver.class); locationListenerPendingIntent = PendingIntent.getBroadcast(this, 0, activeIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent passiveIntent = new Intent(this, PassiveLocationChangedReceiver.class); locationListenerPassivePendingIntent = PendingIntent.getBroadcast(this, 0, passiveIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Instantiate a LastLocationFinder class. // This will be used to find the last known location when the application starts. lastLocationFinder = PlatformSpecificImplementationFactory.getLastLocationFinder(this); lastLocationFinder.setChangedLocationListener(oneShotLastLocationUpdateListener); // Instantiate a Location Update Requester class based on the available platform version. // This will be used to request location updates. locationUpdateRequester = PlatformSpecificImplementationFactory.getLocationUpdateRequester(locationManager); // Create an Intent Filter to listen for checkins newCheckinReceiverName = new ComponentName(this, NewCheckinReceiver.class); newCheckinFilter = new IntentFilter(PlacesConstants.NEW_CHECKIN_ACTION); // Check to see if an Place ID has been specified in the launch Intent. // If so, we should display the details for the specified venue. if (getIntent().hasExtra(PlacesConstants.EXTRA_KEY_ID)) { Intent intent = getIntent(); String key = intent.getStringExtra(PlacesConstants.EXTRA_KEY_ID); if (key != null) { selectDetail(null, key); // Remove the ID from the Intent (so that a resume doesn't reselect). intent.removeExtra(PlacesConstants.EXTRA_KEY_ID); setIntent(intent); } } }
From source file:com.platform.GeoLocationManager.java
public void stopGeoSocket() { final MainActivity app = MainActivity.app; if (app == null) return;/*from w ww .j a v a 2s . com*/ final LocationManager locationManager = (LocationManager) app.getSystemService(Context.LOCATION_SERVICE); app.runOnUiThread(new Runnable() { @Override public void run() { if (ActivityCompat.checkSelfPermission(app, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(app, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { Log.e(TAG, "stopGeoSocket, can't happen"); RuntimeException ex = new RuntimeException("stopGeoSocket, can't happen"); FirebaseCrash.report(ex); throw ex; } locationManager.removeUpdates(socketLocationListener); } }); }
From source file:com.tvs.signaltracker.STService.java
private void InitBase() { Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); MyListener = new MyPhoneStateListener(); mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); NetLocListener = new NETLocationListener(); mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 10, NetLocListener); Tel.listen(MyListener,//w w w. j a va 2 s . co m PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_CELL_LOCATION); //CommonHandler.Operator = Utils.DoOperator(Tel.getNetworkOperatorName()); Operator x = CommonHandler.dbman.getOperator(CommonHandler.MCC, CommonHandler.MNC); if (x != null) CommonHandler.Operator = x.name; else CommonHandler.Operator = CommonHandler.MCC + "" + CommonHandler.MNC; }
From source file:com.inloc.dr.StepService.java
@Override public void onCreate() { Log.i(TAG, "[SERVICE] onCreate"); super.onCreate(); dtr = new DataRecorder(); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); showNotification();// w ww .j a v a 2 s.com // Load settings mSettings = PreferenceManager.getDefaultSharedPreferences(this); mPedometerSettings = new PedometerSettings(mSettings); mState = getSharedPreferences("state", 0); mUtils = Utils.getInstance(); mUtils.setService(this); acquireWakeLock(); // Start detecting mStepDetector = new StepDetector(); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); mTurnDetector = new TurnDetector(); mTurnNotifier = new TurnNotifier(); mTurnNotifier.addListener(mAngleListener); mTurnDetector.addTurnListener(mTurnNotifier); registerDetector(); // Register our receiver for the ACTION_SCREEN_OFF action. This will make our receiver // code be called whenever the phone enters standby mode. IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF); registerReceiver(mReceiver, filter); mStepDisplayer = new StepDisplayer(mPedometerSettings, mUtils); mStepDisplayer.setSteps(mSteps = mState.getInt("steps", 0)); mStepDisplayer.addListener(mStepListener); mStepDetector.addStepListener(mStepDisplayer); lSteps = mSteps; mConnManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); File mExternalRoot = android.os.Environment.getExternalStorageDirectory(); mOutputDir = new File(mExternalRoot.getAbsolutePath() + "/datalogs/"); // attempt to make output directory if (!mOutputDir.exists()) { mOutputDir.mkdirs(); } // Used when debugging: // mStepBuzzer = new StepBuzzer(this); // mStepDetector.addStepListener(mStepBuzzer); // Start voice reloadSettings(); // Tell the user we started. Toast.makeText(this, getText(R.string.started), Toast.LENGTH_SHORT).show(); }
From source file:be.brunoparmentier.openbikesharing.app.activities.MapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); getActionBar().setDisplayHomeAsUpEnabled(true); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); stationsDataSource = new StationsDataSource(this); ArrayList<Station> stations = stationsDataSource.getStations(); map = (MapView) findViewById(R.id.mapView); stationMarkerInfoWindow = new StationMarkerInfoWindow(R.layout.bonuspack_bubble, map); /* handling map events */ MapEventsOverlay mapEventsOverlay = new MapEventsOverlay(this, this); map.getOverlays().add(0, mapEventsOverlay); /* markers list */ GridMarkerClusterer stationsMarkers = new GridMarkerClusterer(this); Drawable clusterIconD = getResources().getDrawable(R.drawable.marker_cluster); Bitmap clusterIcon = ((BitmapDrawable) clusterIconD).getBitmap(); map.getOverlays().add(stationsMarkers); stationsMarkers.setIcon(clusterIcon); stationsMarkers.setGridSize(100);//from w w w . j a v a 2s.c o m for (final Station station : stations) { stationsMarkers.add(createStationMarker(station)); } map.invalidate(); mapController = map.getController(); mapController.setZoom(16); map.setMultiTouchControls(true); map.setBuiltInZoomControls(true); map.setMinZoomLevel(3); /* map tile source */ String mapLayer = settings.getString("pref_map_layer", ""); switch (mapLayer) { case "mapnik": map.setTileSource(TileSourceFactory.MAPNIK); break; case "cyclemap": map.setTileSource(TileSourceFactory.CYCLEMAP); break; case "osmpublictransport": map.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT); break; case "mapquestosm": map.setTileSource(TileSourceFactory.MAPQUESTOSM); break; default: map.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE); break; } GpsMyLocationProvider imlp = new GpsMyLocationProvider(this.getBaseContext()); imlp.setLocationUpdateMinDistance(1000); imlp.setLocationUpdateMinTime(60000); myLocationOverlay = new MyLocationNewOverlay(this.getBaseContext(), imlp, this.map); map.getOverlays().add(this.myLocationOverlay); myLocationOverlay.enableMyLocation(); try { LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); GeoPoint userLocation = new GeoPoint( locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)); mapController.animateTo(userLocation); } catch (NullPointerException e) { mapController.setZoom(13); double bikeNetworkLatitude = Double.longBitsToDouble(settings.getLong(PREF_KEY_NETWORK_LATITUDE, 0)); double bikeNetworkLongitude = Double.longBitsToDouble(settings.getLong(PREF_KEY_NETWORK_LONGITUDE, 0)); mapController.animateTo(new GeoPoint(bikeNetworkLatitude, bikeNetworkLongitude)); Toast.makeText(this, R.string.location_not_found, Toast.LENGTH_LONG).show(); } }
From source file:com.uproot.trackme.LocationActivity.java
/** * This sample demonstrates how to incorporate location based services in your * app and process location updates. The app also shows how to convert * lat/long coordinates to human-readable addresses. *//*from w ww. j a va2 s . c o m*/ @SuppressLint({ "NewApi", "HandlerLeak" }) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // clearDB(); initDatabase(); Button btn1 = (Button) findViewById(R.id.btn1); btn1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub finish(); } }); if (savedInstanceState != null) { mUseFine = savedInstanceState.getBoolean(KEY_FINE); mUseBoth = savedInstanceState.getBoolean(KEY_BOTH); } else { mUseFine = false; mUseBoth = false; } mUseFine = false; mUseBoth = true; mLatLng = (TextView) findViewById(R.id.latlng); mAddress = (TextView) findViewById(R.id.address); // The isPresent() helper method is only available on Gingerbread or // above. mGeocoderAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Geocoder.isPresent(); // Handler for updating text fields on the UI like the lat/long and // address. mHandler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case UPDATE_ADDRESS: mAddress.setText((String) msg.obj); break; case UPDATE_LATLNG: mLatLng.setText((String) msg.obj); break; } } }; // Get a reference to the LocationManager object. mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); setup(); myTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { getLocs(); } }, 0, setF * 1000); }
From source file:cd.education.data.collector.android.activities.GeoPointMapActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { mLocationCount = savedInstanceState.getInt(LOCATION_COUNT); }/*from ww w.j a v a 2 s.c om*/ requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.geopoint_layout); Intent intent = getIntent(); mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY; if (intent != null && intent.getExtras() != null) { if (intent.hasExtra(GeoPointWidget.LOCATION)) { double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION); mLatLng = new LatLng(location[0], location[1]); } if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) { mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD, GeoPointWidget.DEFAULT_LOCATION_ACCURACY); } mCaptureLocation = !intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false); mRefreshLocation = mCaptureLocation; } /* Set up the map and the marker */ mMarkerOption = new MarkerOptions(); mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); mMap.setOnMarkerDragListener(this); mLocationStatus = (TextView) findViewById(R.id.location_status); /*Zoom only if there's a previous location*/ if (mLatLng != null) { mLocationStatus.setVisibility(View.GONE); mMarkerOption.position(mLatLng); mMarker = mMap.addMarker(mMarkerOption); mRefreshLocation = false; // just show this position; don't change it... mMarker.setDraggable(mCaptureLocation); mZoomed = true; mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16)); } mCancelLocation = (Button) findViewById(R.id.cancel_location); mCancelLocation.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Collect.getInstance().getActivityLogger().logInstanceAction(this, "cancelLocation", "cancel"); finish(); } }); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // make sure we have a good location provider before continuing List<String> providers = mLocationManager.getProviders(true); for (String provider : providers) { if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) { mGPSOn = true; } if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) { mNetworkOn = true; } } if (!mGPSOn && !mNetworkOn) { Toast.makeText(getBaseContext(), getString(R.string.provider_disabled_error), Toast.LENGTH_SHORT) .show(); finish(); } if (mGPSOn) { Location loc = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (loc != null) { InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis() + " lastKnownLocation(GPS) lat: " + loc.getLatitude() + " long: " + loc.getLongitude() + " acc: " + loc.getAccuracy()); } else { InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis() + " lastKnownLocation(GPS) null location"); } } if (mNetworkOn) { Location loc = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (loc != null) { InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis() + " lastKnownLocation(Network) lat: " + loc.getLatitude() + " long: " + loc.getLongitude() + " acc: " + loc.getAccuracy()); } else { InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis() + " lastKnownLocation(Network) null location"); } } mAcceptLocation = (Button) findViewById(R.id.accept_location); if (mCaptureLocation) { mAcceptLocation.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Collect.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation", "OK"); returnLocation(); } }); mMap.setOnMapLongClickListener(this); } else { mAcceptLocation.setVisibility(View.GONE); } mReloadLocation = (Button) findViewById(R.id.reload_location); if (mCaptureLocation) { mReloadLocation.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mRefreshLocation = true; mReloadLocation.setVisibility(View.GONE); mLocationStatus.setVisibility(View.VISIBLE); if (mGPSOn) { mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, GeoPointMapActivity.this); } if (mNetworkOn) { mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, GeoPointMapActivity.this); } } }); mReloadLocation.setVisibility(!mRefreshLocation ? View.VISIBLE : View.GONE); } else { mReloadLocation.setVisibility(View.GONE); } // Focuses on marked location mShowLocation = ((Button) findViewById(R.id.show_location)); mShowLocation.setVisibility(View.VISIBLE); mShowLocation.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Collect.getInstance().getActivityLogger().logInstanceAction(this, "showLocation", "onClick"); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16)); } }); mShowLocation.setClickable(mMarker != null); }
From source file:com.mpower.clientcollection.activities.GeoPointMapActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { mLocationCount = savedInstanceState.getInt(LOCATION_COUNT); }/* w ww . ja v a2s .com*/ requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.geopoint_layout); Intent intent = getIntent(); mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY; if (intent != null && intent.getExtras() != null) { if (intent.hasExtra(GeoPointWidget.LOCATION)) { double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION); mLatLng = new LatLng(location[0], location[1]); } if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) { mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD, GeoPointWidget.DEFAULT_LOCATION_ACCURACY); } mCaptureLocation = !intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false); mRefreshLocation = mCaptureLocation; } /* Set up the map and the marker */ mMarkerOption = new MarkerOptions(); mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); mMap.setOnMarkerDragListener(this); mLocationStatus = (TextView) findViewById(R.id.location_status); /*Zoom only if there's a previous location*/ if (mLatLng != null) { mLocationStatus.setVisibility(View.GONE); mMarkerOption.position(mLatLng); mMarker = mMap.addMarker(mMarkerOption); mRefreshLocation = false; // just show this position; don't change it... mMarker.setDraggable(mCaptureLocation); mZoomed = true; mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16)); } mCancelLocation = (Button) findViewById(R.id.cancel_location); mCancelLocation.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ClientCollection.getInstance().getActivityLogger().logInstanceAction(this, "cancelLocation", "cancel"); finish(); } }); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // make sure we have a good location provider before continuing List<String> providers = mLocationManager.getProviders(true); for (String provider : providers) { if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) { mGPSOn = true; } if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) { mNetworkOn = true; } } if (!mGPSOn && !mNetworkOn) { Toast.makeText(getBaseContext(), getString(R.string.provider_disabled_error), Toast.LENGTH_SHORT) .show(); finish(); } if (mGPSOn) { Location loc = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (loc != null) { InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis() + " lastKnownLocation(GPS) lat: " + loc.getLatitude() + " long: " + loc.getLongitude() + " acc: " + loc.getAccuracy()); } else { InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis() + " lastKnownLocation(GPS) null location"); } } if (mNetworkOn) { Location loc = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (loc != null) { InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis() + " lastKnownLocation(Network) lat: " + loc.getLatitude() + " long: " + loc.getLongitude() + " acc: " + loc.getAccuracy()); } else { InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis() + " lastKnownLocation(Network) null location"); } } mAcceptLocation = (Button) findViewById(R.id.accept_location); if (mCaptureLocation) { mAcceptLocation.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ClientCollection.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation", "OK"); returnLocation(); } }); mMap.setOnMapLongClickListener(this); } else { mAcceptLocation.setVisibility(View.GONE); } mReloadLocation = (Button) findViewById(R.id.reload_location); if (mCaptureLocation) { mReloadLocation.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mRefreshLocation = true; mReloadLocation.setVisibility(View.GONE); mLocationStatus.setVisibility(View.VISIBLE); if (mGPSOn) { mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, GeoPointMapActivity.this); } if (mNetworkOn) { mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, GeoPointMapActivity.this); } } }); mReloadLocation.setVisibility(!mRefreshLocation ? View.VISIBLE : View.GONE); } else { mReloadLocation.setVisibility(View.GONE); } // Focuses on marked location mShowLocation = ((Button) findViewById(R.id.show_location)); mShowLocation.setVisibility(View.VISIBLE); mShowLocation.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ClientCollection.getInstance().getActivityLogger().logInstanceAction(this, "showLocation", "onClick"); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16)); } }); mShowLocation.setClickable(mMarker != null); }