You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement LocationManager and orientation sensor using libportal
This commit is contained in:
31
src/api-impl/android/location/LocationManager.java
Normal file
31
src/api-impl/android/location/LocationManager.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package android.location;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class LocationManager {
|
||||
|
||||
static Set<LocationListener> listeners = new HashSet<>();
|
||||
|
||||
public String getBestProvider(Criteria criteria, boolean enabledOnly) {
|
||||
return "xdgportal";
|
||||
}
|
||||
|
||||
public Location getLastKnownLocation(String provider) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void requestLocationUpdates (String provider, long minTimeMs, float minDistanceM, LocationListener listener) {
|
||||
listeners.add(listener);
|
||||
nativeGetLocation();
|
||||
}
|
||||
|
||||
private native void nativeGetLocation();
|
||||
|
||||
private static void locationUpdated(double latitude, double longitude, double heading) {
|
||||
for (LocationListener locationListener : listeners) {
|
||||
locationListener.onLocationChanged(new Location(latitude, longitude, heading));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user