java - Methods onLocationChanged -
I'm trying to run a method when the current location changes occur. It calculates the distance of change in the current location every time and then shows it in the textview.
public GoogleMap googleMap; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.activity_main); // Final Media Player mPlayer = MediaPlayer.create (FakeCallScreen.this, R.raw.mysoundfile); // Get status of Google Play availability status = GooglePlayServicesUtil.isGooglePlayServicesAvailable (getBaseContext ()); // If you want to show status (status! = Connection result.UCCE) {// Google Play services are not available int requests codes = 10; Dialog dialog = GooglePlayServicesUtil.getErrorDialog (status, this, requestCode); Dialog.show (); } Else {// Google Play services are available // Getting activity_main.xml in the context of SupportMapFragment. SupportMapFragmentfm = (SupportMapFragment) getSupportFragmentManager (). FindFragmentById (R.id.map); // Get GoogleMap Object from GoogleMap = fm.getMap (); // Enabling Google Map's MyLocation Layer; GoogleMap.setMyLocationEnabled (true); // System Service LOCATION_SERVICE LocationManager Getting LocationManager object from locationManager (Location Manager) getSystemService (LOCATION_SERVICE); // Creating criteria criteria for obtaining provider criteria - Criteria = new criteria (); // Getting the name of the best provider string provider = locationManager.getBestProvider (criteria, true); // Create an existing location Location Location = locationManager.getLastKnownLocation (Provider); If (location! = Null) {onLocationChanged (location); LocationManager.requestLocationUpdates (Provider, 20000, 0, (LocationListener this); Location marker = new location (""); Marker.setLatitude (lat); Marker.setLongitude (long1); If (choose == incorrect) {text view t = (TextView) findViewById (R.id.tv_location); T.setText ("Please select a marker" + latitude + long 1); Toast. Make text (this, "not selected", toast. LNNHH_LOG). Show (); } And if (choose == true) {float distanceBitine points = location.distanceTo (marker); TextView t = (TextView) findViewById (R.id.tv_location); T.setText ("Distance from station" + Distance + BBB points); Toast. Make text (this, "distance" + distancebb points, toast. Lnnht_log). Show (); If (distanceBetweenPoints & lt; 1000) {// do something}}} and onInfoWindow code
googleMap.setOnInfoWindowClickListener (New OnInfoWindowClickListener () {public zero onInfoWindowClick (marker marker) {LatLng clickedMarkerLatLng = marker.getPosition (); lat = clickedMarkerLatLng.latitude; long1 = clickedMarkerLatLng.longitude; string name = marker.getTitle (); select = true TextView t = (TextView) findViewById (Free. Id.tv_location); t.setText (+ name "is" + long1 + latitude + "to" + "with the location of"); I will go about making this run when Location change?
as you / Div>
Comments
Post a Comment