You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `ion-android-geolocation` is a library built using `Kotlin` that provides geolocation features for Android applications.
4
+
5
+
The `IONGLOCController` class provides the main features of the Library, which are:
6
+
- obtaining the location/position of the device a single time;
7
+
- adding a watch to obtain periodic location updates;
8
+
- clearing/removing a previously added watch, turning off location updates.
9
+
10
+
11
+
## Index
12
+
13
+
-[Motivation](#motivation)
14
+
-[Usage](#usage)
15
+
-[Methods](#methods)
16
+
-[Obtain the current location of the device](#obtain-the-current-location-of-the-device)
17
+
-[Add a watch for periodic location updates](#add-a-watch-for-periodic-location-updates)
18
+
-[Clear a watch that was added previously](#clear-a-watch-that-was-added-previously)
19
+
-[Troubleshooting](#troubleshooting)
20
+
-[Contributing](#contributing)
21
+
-[License](#license)
22
+
-[Support](#support)
23
+
24
+
## Motivation
25
+
26
+
This library is used by the Geolocation Plugin for [OutSystems' Cordova Plugin](https://github.com/ionic-team/cordova-outsystems-geolocation) and [Ionic's Capacitor Plugin](https://github.com/ionic-team/outsystems-geolocation).
27
+
28
+
## Usage
29
+
30
+
In your app-level gradle file, import the `ion-android-geolocation` library like so:
As mentioned before, the library offers the `IONGLOCController` class that provides the following methods to interact with:
41
+
42
+
### Obtain the current location of the device
43
+
44
+
```kotlin
45
+
suspendfungetCurrentPosition(
46
+
activity:Activity,
47
+
options:IONGLOCLocationOptions
48
+
): Result<IONGLOCLocationResult>
49
+
```
50
+
51
+
The method is composed of the following input parameters:
52
+
-**activity**: the `Activity` from the app using the library to use when obtaining the location.
53
+
-**options**: `IONGLOCLocationOptions` with the options with which to make the location request with (e.g. timeout).
54
+
55
+
The method returns a `Result` containing either an object of type `IONGLOCLocationResult`, which includes the geolocation data (e.g. latitide, longitude), or an exception that should be handled by the caller app.
56
+
57
+
### Add a watch for periodic location updates
58
+
59
+
```kotlin
60
+
funaddWatch(
61
+
activity:Activity,
62
+
options:IONGLOCLocationOptions,
63
+
watchId:String
64
+
): Flow<Result<List<IONGLOCLocationResult>>>
65
+
```
66
+
67
+
The method is composed of the following input parameters:
68
+
-**activity**: the `Activity` from the app using the library to use when obtaining the location updates.
69
+
-**options**: `IONGLOCLocationOptions` with the options with which to make the location updates request with (e.g. timeout).
70
+
-**watchId**: a unique id identifying the watch to add, so that it can be removed later.
71
+
72
+
The method returns a Flow in which the location updates will be emitted to.
73
+
74
+
### Clear a watch that was added previously
75
+
76
+
```kotlin
77
+
funclearWatch(id:String): Boolean
78
+
```
79
+
80
+
The method is composed of the following input parameters:
81
+
-**id**: the `watchId` identigying the watch to remove.
82
+
83
+
The method returns a Boolean indicating if the watch was cleared or not (in case the watch isn't found).
84
+
85
+
## Troubleshooting
86
+
87
+
Common issues and solutions:
88
+
89
+
1. Location updates not received
90
+
- Check that location permission is allowed on the device
91
+
- Verify location services are enabled on the device
92
+
- Ensure the necessary permissions are included in `AndroidManifest.xml`
93
+
94
+
2. Poor accuracy
95
+
- Enable high accuracy mode
96
+
- Ensure clear sky view
97
+
- Wait for better GPS signal
98
+
99
+
## Contributing
100
+
101
+
1. Fork the repository
102
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
103
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
104
+
4. Push to the branch (`git push origin feature/amazing-feature`)
105
+
5. Open a Pull Request
106
+
107
+
## License
108
+
109
+
`ion-android-geolocation` is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
110
+
111
+
## Support
112
+
113
+
- Report issues on our [Issue Tracker](https://github.com/ionic-team/ion-android-geolocation/issues)
0 commit comments