【发布时间】:2019-12-10 03:06:03
【问题描述】:
任何人都知道如何在本机反应中获得卫星数量。目前,我正在使用 https://github.com/react-native-community/react-native-geolocation 但它没有给出卫星的数量
【问题讨论】:
标签: android react-native mobile geolocation location
任何人都知道如何在本机反应中获得卫星数量。目前,我正在使用 https://github.com/react-native-community/react-native-geolocation 但它没有给出卫星的数量
【问题讨论】:
标签: android react-native mobile geolocation location
对于 Android,您可以通过本机模块获取 inf。在android原生中,可以使用localManager获取卫星数量。
privateLocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
//it uses GPS, so you have to check if GPS is working
//add the listener
manager.registerGnssStatusCallback(gpsStatusListener);
private GpsStatus.Callback gpsStatusListener = new GpsStatus.Callback() {
@Override
public void onSatelliteStatusChanged(GnssStatus status) {
int count = status.getSatelliteCount()
}
};
react-native 原生模块的写法可以看官方文档; 对于ios,它无法获取信息。
你也可以使用这个react-native-location-satellites来获取。
【讨论】: