title: Get location android Kotlin
body: <p>I recently added get location function. When I try to show longitude and latitude, it returns zero.</p>
  
  <p>This my LocationListener class:</p>
  
  <pre><code>inner class MylocationListener: LocationListener {
      constructor():super(){
          mylocation= Location("me")
          mylocation!!.longitude
          mylocation!!.latitude
      }
  
      override fun onLocationChanged(location: Location?) {
          mylocation=location
      }
  
      override fun onStatusChanged(p0: String?, p1: Int, p2: Bundle?) {}
  
      override fun onProviderEnabled(p0: String?) {}
  
      override fun onProviderDisabled(p0: String?) {}
  }
  </code></pre>
  
  <p>And this my GetUserLocation function:</p>
  
  <pre><code>fun GetUserLocation(){
      var mylocation= MylocationListener()
      var locationManager=getSystemService(Context.LOCATION_SERVICE) as LocationManager
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0.1f,mylocation)
  }
  </code></pre>
  
  <p>And this my function to return my longitude and latitude:</p>
  
  <pre><code>fun getLoction (view: View){
      prgDialog!!.show();
  
      GetUserLocation()
  
      button.setTextColor(getResources().getColor(R.color.green));
      textView.text = mylocation!!.latitude.toFloat().toString()
      Toast.makeText(this, mylocation!!.latitude.toFloat().toString(), Toast.LENGTH_LONG).show()
      Toast.makeText(this, mylocation!!.longitude.toFloat().toString(), Toast.LENGTH_LONG).show()
  
      prgDialog!!.hide()
  } 
  </code></pre>