Skip to content

Instantly share code, notes, and snippets.

@mizutori
Created May 27, 2021 08:24
Show Gist options
  • Select an option

  • Save mizutori/d06c264b61f4eddb6eda0a4652be0d97 to your computer and use it in GitHub Desktop.

Select an option

Save mizutori/d06c264b61f4eddb6eda0a4652be0d97 to your computer and use it in GitHub Desktop.

Revisions

  1. mizutori created this gist May 27, 2021.
    26 changes: 26 additions & 0 deletions LocationListener
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {
    if (provider == LocationManager.GPS_PROVIDER) {
    if (status == LocationProvider.OUT_OF_SERVICE) {
    notifyLocationProviderStatusUpdated(false)
    } else {
    notifyLocationProviderStatusUpdated(true)
    }
    }
    }

    override fun onProviderEnabled(provider: String?) {
    if (provider == LocationManager.GPS_PROVIDER) {
    notifyLocationProviderStatusUpdated(true)
    }
    }

    override fun onProviderDisabled(provider: String?) {
    if (provider == LocationManager.GPS_PROVIDER) {
    notifyLocationProviderStatusUpdated(false)
    }

    }

    private fun notifyLocationProviderStatusUpdated(isLocationProviderAvailable: Boolean) {
    //Broadcast location provider status change here
    }