https://github.com/rommansabbir/locationlistener-android
A simple library for Android to get current geo location
https://github.com/rommansabbir/locationlistener-android
Last synced: about 2 months ago
JSON representation
A simple library for Android to get current geo location
- Host: GitHub
- URL: https://github.com/rommansabbir/locationlistener-android
- Owner: rommansabbir
- Created: 2019-02-23T08:46:31.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-15T11:27:02.000Z (about 6 years ago)
- Last Synced: 2025-01-30T15:16:53.236Z (4 months ago)
- Language: Kotlin
- Homepage:
- Size: 132 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LocationListener-Android
## Documentation
### Installation
---
Step 1. Add the JitPack repository to your build file```gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```Step 2. Add the dependency
```gradle
dependencies {
implementation 'com.github.rommansabbir:LocationListener-Android:Tag'
}
```---
### Version available
| Releases
| ------------- |
| v1.1 |
| v1.0.1 |
| v1.0 |# Usages
### For Java:
```Kotlin
class MainActivity : AppCompatActivity(), PermissionCallback {override fun onPermissionRequest(isGranted: Boolean) {
/**
* Check if granted or not
*/
if(isGranted){
/**
* Get location after a period of time
*/
LocationListener.getLocationPeriodic(5000, object : LocationCallback {
override fun onLocationSuccess(location: Location) {
Toast.makeText(this@MainActivity, "${location.latitude}, ${location.longitude}", Toast.LENGTH_SHORT).show()
}
})
/**
* Get location for a single time
*/
LocationListener.getLocation(object : LocationCallback{
override fun onLocationSuccess(location: Location) {
Toast.makeText(this@MainActivity, "${location.latitude}, ${location.longitude}", Toast.LENGTH_SHORT).show()
}
})
}
}override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
/**
* Set LocationListener component with activity
*/
LocationListener.setComponent(this)
}override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
/**
* Pass to the LocationListener
*/
LocationListener.processResult(requestCode, permissions, grantResults)
}override fun onDestroy() {
super.onDestroy()
/**
* Self Destroy LocationListener
*/
LocationListener.selfDestroy()
}
}```
### Contact me
[Portfolio](https://www.rommansabbir.com/) | [LinkedIn](https://www.linkedin.com/in/rommansabbir/) | [Twitter](https://www.twitter.com/itzrommansabbir/) | [Facebook](https://www.facebook.com/itzrommansabbir/)