|
1 | 1 | package com.singularity_code.live_location.util.other; |
2 | 2 |
|
3 | 3 | import android.content.Context; |
| 4 | +import android.os.Build; |
4 | 5 | import androidx.core.app.NotificationCompat; |
| 6 | +import com.google.android.gms.location.LocationResult; |
5 | 7 | import com.singularity_code.live_location.util.enums.NetworkMethod; |
6 | 8 | import com.singularity_code.live_location.util.pattern.*; |
7 | 9 | import org.jetbrains.annotations.NotNull; |
@@ -33,6 +35,16 @@ public String getLatitude() { |
33 | 35 | return _latitude; |
34 | 36 | } |
35 | 37 |
|
| 38 | + private String _altitude; |
| 39 | + |
| 40 | + public String getAltitude() { |
| 41 | + return _altitude; |
| 42 | + } |
| 43 | + |
| 44 | + private String _altitudeAccuracyMeter; |
| 45 | + public String getAltitudeAccuracyMeter() { |
| 46 | + return _altitudeAccuracyMeter; |
| 47 | + } |
36 | 48 | private String _longitude; |
37 | 49 |
|
38 | 50 | public String getLongitude() { |
@@ -209,11 +221,21 @@ public void onError(String message) { |
209 | 221 | } |
210 | 222 |
|
211 | 223 | @Override |
212 | | - public void onReceiveUpdate(double latitude, double longitude, float accuracy, long updateTime) { |
213 | | - AlienPortal.this._latitude = String.valueOf(latitude); |
214 | | - AlienPortal.this._longitude = String.valueOf(longitude); |
215 | | - AlienPortal.this._accuracy = String.valueOf(accuracy); |
216 | | - AlienPortal.this._updatedTime = String.valueOf(updateTime); |
| 224 | + public void onReceiveUpdate(@NotNull LocationResult location) { |
| 225 | + if (location.getLastLocation() == null) return; |
| 226 | + |
| 227 | + AlienPortal.this._latitude = String.valueOf(location.getLastLocation().getLatitude()); |
| 228 | + AlienPortal.this._longitude = String.valueOf(location.getLastLocation().getLongitude()); |
| 229 | + AlienPortal.this._accuracy = String.valueOf(location.getLastLocation().getAccuracy()); |
| 230 | + AlienPortal.this._updatedTime = String.valueOf(location.getLastLocation().getTime()); |
| 231 | + |
| 232 | + if (location.getLastLocation().hasAltitude()) { |
| 233 | + AlienPortal.this._altitude = String.valueOf(location.getLastLocation().getAltitude()); |
| 234 | + |
| 235 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| 236 | + AlienPortal.this._altitudeAccuracyMeter = String.valueOf(location.getLastLocation().getVerticalAccuracyMeters()); |
| 237 | + } |
| 238 | + } |
217 | 239 | } |
218 | 240 | }; |
219 | 241 |
|
|
0 commit comments