https://github.com/marplex/gpslocation
An android kotlin library to easily access gps location
https://github.com/marplex/gpslocation
Last synced: 8 months ago
JSON representation
An android kotlin library to easily access gps location
- Host: GitHub
- URL: https://github.com/marplex/gpslocation
- Owner: Marplex
- License: apache-2.0
- Created: 2022-03-22T17:28:34.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-22T18:17:44.000Z (almost 4 years ago)
- Last Synced: 2025-03-25T13:46:50.251Z (11 months ago)
- Language: Kotlin
- Size: 138 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
gpslocation
An android kotlin library to easily access gps location
It uses Fused Location Provider API and Android Location API if google services are not installed
## Download
```gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```
```gradle
dependencies {
implementation "com.github.Marplex:gpslocation:1.0.0"
}
```
## Usage
```kotlin
val gpsLocation = GPSLocation(context)
```
```kotlin
// Start and stop location updates
gpsLocation.startLocationUpdates()
gpsLocation.stopLocationUpdates()
```
```kotlin
//Get last cached best location
gpsLocation.getLastKnownLocation { location -> println(location) }
//Get current location (with active location computation)
gpsLocation.getCurrentLocation { location -> println(location) }
```
```kotlin
// Listen for location updates and status
gpsLocation.gpsLocationListener = object: GpsLocationListener {
override fun onLocationReceived(locations: List) { }
override fun onLocationStatusReceived(status: LocationStatus) {
when(status) {
LocationStatus.MISSING_PERMISSIONS -> TODO("Ask gps permissions")
LocationStatus.PERMISSIONS_DENIED -> TODO("Ask gps permissions")
LocationStatus.NO_GPS -> gpsLocation.showLocationSettings(this)
}
}
}
```
## License
```xml
Copyright 2022 marplex (Marco Cimolai)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.