Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. class LocationFragment : Fragment() {
  2.  
  3. private lateinit var mFusedLocationProviderClient: FusedLocationProiderClient
  4.  
  5. override fun onCreate(savedInstanceState: Bundle?) {
  6. mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(activity)
  7. }
  8.  
  9. override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
  10. // Initialize button on-click callback.
  11. }
  12.  
  13. private fun getCurrentLocation() {
  14. // Check that the location service is enabled.
  15. // Check coarse and fine location permissions.
  16.  
  17. mFusedLocationProviderClient.lastLocation.addOnSuccessListener {
  18. if (it != null) { // Always false if location services are toggled.
  19. print(it.latitude, it.longitude)
  20. }
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement