Flutter的地球座软件包将返回纬度和经度值的零。为什么? [安卓]

发布于 2025-02-08 08:16:27 字数 2693 浏览 4 评论 0 原文

这是我的第一个堆叠式问题,我正在学习新手的飞镖和扑朔迷离。

我已被介绍给 Geolocator 软件包,我一直在使用最新版本 8.2.1 。我还与Android Studio及其Android模拟器合作。

面临的挑战是获得纬度和经度值,这些值来自地理座器获得的位置数据。

经过一些测试,结果是启用了位置服务,授予了要注意的位置数据的许可,但是尽管如此,地理位置数据仍未检索到位置数据。

我在仿真器的设置上度过了一段时间,并设法在加利福尼亚州圣何塞设置了一个位置,我希望地理定位器会找到并使用,但这样做没有区别。

控制台的响应似乎很重要,即“未来未完成”:

✓构建构建/app/upputs/flutter-apk/app-debug.apk。 安装build/app/outputs/flutter-apk/app.apk ... D/FlutterGeolocator(6027):将地理定位器附加到活动 D/FlutterGeolocator(6027):创建服务。 D/FlutterGeolocator(6027):与位置服务结合。 D/FlutterGeolostotor(6027):Geolocator前景服务连接 D/FlutterGeolostotor(6027):初始化地理定位器服务 调试服务在ws://127.0.0.1:64162/f6u62iu6Oxc =/ws上聆听 将文件同步到设备SDK GPHONE64 x86 64 ... I/Flutter(6027):当前,模拟器的位置服务状态= true。 D/CompatibilityChangeReporter(6027):兼容更改ID报告:78294732; UID 10149;状态:启用 I/Flutter(6027):当前位置权限状态= tacterpermission.whileinuse。 I/Flutter(6027):0:00:05.000000之后的TimeOutException:未来未完成

我的代码:

import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

void main() {
  runApp(ScreenView());
}

class ScreenView extends StatefulWidget {
  double? latitude;
  double? longitude;

  ScreenView({this.latitude, this.longitude});

  void locationHereIs() async {
    await locationServicesStatus();
    await checkLocationPermissions();
    try {
      Position position = await Geolocator.getCurrentPosition(
              desiredAccuracy: LocationAccuracy.low)
          .timeout(Duration(seconds: 5));
      print(position);
    } catch (e) {
      print(e);
    }
  }

  Future<void> checkLocationPermissions() async {
    LocationPermission permission = await Geolocator.requestPermission();
    print('Current Location Permission Status = $permission.');
  }

  void checkLocationSettings() async {
    await Geolocator.openLocationSettings();
  }

  Future<void> locationServicesStatus() async {
    bool isLocationServiceEnabled = await Geolocator.isLocationServiceEnabled();
    print(
        'Currently, the emulator\'s Location Services Status = $isLocationServiceEnabled.');
  }

  @override
  State<ScreenView> createState() => _ScreenViewState();
}

class _ScreenViewState extends State<ScreenView> {
  @override
  void initState() {
    ScreenView().locationHereIs();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

如果您可以帮助我了解出了什么问题,以便我可以解决问题并获得结果,那将是完美的。在您的回应中,请假设我使用了 crumpilesdkversion 32 minisdkversion 23 targetsdkversion 32

感谢:)

This is my first StackOverflow question and I am learning Dart and Flutter as a newbie.

I have been introduced to the geolocator package and I have been using the latest version which is version 8.2.1. I am also working with Android Studio and its Android Emulator.

The challenge has been to gain latitude and longitude values, and these would come from position data acquired by geolocator.

After some tests, the results have been that the location services are enabled, permission for the location data to be noticed is granted, but despite this, the position data is not being retrieved by geolocator.

I spent some time in the emulator's settings and managed to set a location in San Jose, California, which I hoped that geolocator would then find and work with, but doing so made no difference.

The console's response which seems important is "Future Not Completed":

✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
D/FlutterGeolocator( 6027): Attaching Geolocator to activity
D/FlutterGeolocator( 6027): Creating service.
D/FlutterGeolocator( 6027): Binding to location service.
D/FlutterGeolocator( 6027): Geolocator foreground service connected
D/FlutterGeolocator( 6027): Initializing Geolocator services
Debug service listening on ws://127.0.0.1:64162/f6U62iu6OXc=/ws
Syncing files to device sdk gphone64 x86 64...
I/flutter ( 6027): Currently, the emulator's Location Services Status = true.
D/CompatibilityChangeReporter( 6027): Compat change id reported: 78294732; UID 10149; state: ENABLED
I/flutter ( 6027): Current Location Permission Status = LocationPermission.whileInUse.
I/flutter ( 6027): TimeoutException after 0:00:05.000000: Future not completed

My Code:

import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

void main() {
  runApp(ScreenView());
}

class ScreenView extends StatefulWidget {
  double? latitude;
  double? longitude;

  ScreenView({this.latitude, this.longitude});

  void locationHereIs() async {
    await locationServicesStatus();
    await checkLocationPermissions();
    try {
      Position position = await Geolocator.getCurrentPosition(
              desiredAccuracy: LocationAccuracy.low)
          .timeout(Duration(seconds: 5));
      print(position);
    } catch (e) {
      print(e);
    }
  }

  Future<void> checkLocationPermissions() async {
    LocationPermission permission = await Geolocator.requestPermission();
    print('Current Location Permission Status = $permission.');
  }

  void checkLocationSettings() async {
    await Geolocator.openLocationSettings();
  }

  Future<void> locationServicesStatus() async {
    bool isLocationServiceEnabled = await Geolocator.isLocationServiceEnabled();
    print(
        'Currently, the emulator\'s Location Services Status = $isLocationServiceEnabled.');
  }

  @override
  State<ScreenView> createState() => _ScreenViewState();
}

class _ScreenViewState extends State<ScreenView> {
  @override
  void initState() {
    ScreenView().locationHereIs();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

If you can help me understand what's going wrong so that I can fix things and get results, that'd be perfect. In your response, please assume that I have used complileSdkVersion 32, miniSdkVersion 23 and targetSdkVersion 32.

With thanks : )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

千寻… 2025-02-15 08:16:27

这里的问题与指定所需的准确性有关。如果是Mathems32,则将其设置为 locationAccuracy.low 。在Android上,这转化为设置,这意味着Android只能使用蜂窝网络来对设备的位置进行三角测量。这将在真实设备(只要具有蜂窝连接)上起作用,但不幸的是在模拟器上不使用。

getlastnoneposition 没有直接关系。 getlastKnowposition 映射到 getlastLocation 在Android fusedlocationProviderClient API上,该api api,该API根据 documentation

返回当前可用的最新历史位置。如果没有历史位置,将返回null。历史位置可能是任意年龄的,因此客户应检查该位置是否适合其目的的年龄。

getCurrentPosition 将始终尝试返回实际位置(或 null ,如果无法确定实际位置),而 getlastnoineposition 将(非常快速) )返回由设备缓存的最后一个已知位置(或 null ,如果没有位置被缓存)。后者可能很旧,根本不代表,因此您应始终检查其时间戳,并确定该位置是否足够用于您的需求。

如果您想测试模拟器上的位置,将所需的精度设置为 locationAccuracy.high 或更高版本。下面是一张表,显示了地理定位器使用的精度与它们映射到Android优先级之间的翻译:

地理位置 Android android
locationAccuracy.lowest priartity_passive
locationAccuracy.low priority_low_power
locationAccuracy.medium priartity_balenced_power_accuracy
locationAccuracy.high PRIORITY_HIGH_ACCURACY
LocationAccuracy.best PRIORITY_HIGH_ACCURACY
LocationAccuracy.bestForNavigation

更新(另请参阅在GitHub上):

结论Android模拟器不支持 getCurrentPosition 方法不正确。我已经运行了您附加的代码,在Android Emulator(Android Pixel 5 -api 30)上键入 desiredAccuracy too locationAccuracy.high ,并正确地报告了配置的位置。这是输出:

W/GooglePlayServicesUtil( 2212): Google Play Store is missing.
I/flutter ( 2212): Currently, the emulator's Location Services Status = true.
I/flutter ( 2212): Current Location Permission Status = LocationPermission.whileInUse.
W/GooglePlayServicesUtil( 2212): Google Play Store is missing.
I/flutter ( 2212): Latitude: 52.56731333333333, Longitude: 5.641091666666666

这是我的使用方式:

  1. 启动Android模拟器。
  2. 启动后,我使用模拟器设置配置了一个位置(请参阅附件,并确保按“设置位置”按钮)。
  3. 现在开始运行示例应用程序。
  4. 检查控制台以获取调试信息。

我确实注意到有时Android模拟器不想播放不错,并且在模拟器捡起它之前,我必须将位置设置好几次。我只有一个新鲜的仿真器就经历了这一点,一旦我拥有不断工作的初始位置,就可以了。可能会有所帮助的是在Android模拟器设置中设置路线并重复播放。

还要确保 android/app/src/main/androidmanifest.xml 包含正确的权限( access_coarse_location access_fine_location )摘要:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.issue_1082">

   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 
   <application
        android:label="issue_1082"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

PS,对于它的价值,我是Geolocator包的作者和维护者。

The problem here is related to the specified desired accuracy. In case of mathems32 it is set to LocationAccuracy.low. On Android this translates to the PRIORITY_LOW_POWER setting which means Android will only use the cellular network to triangulate the device's location. This will work on real devices (as long as they have a cellular connection) but doesn't on the emulator unfortunately.

There is no direct relationship to the getLastKnownPosition. The getLastKnowPosition maps to the getLastLocation on the Android FusedLocationProviderClient API which according to the documentation:

Returns the most recent historical location currently available. Will return null if no historical location is available. The historical location may be of an arbitrary age, so clients should check how old the location is to see if it suits their purposes.

The getCurrentPosition will always try to return the actual location (or null if the actual location cannot be determined), while the getLastKnownPosition will (very quickly) return the last known position which is cached by the device (or null if no location is cached). The later might be very old and not representative at all, therefore you should always check its timestamp and determine if the position is recent enough to use for your needs.

If you'd like to test the location on the emulator set the desired accuracy to LocationAccuracy.high or higher. Below is a table showing the translation between the accuracies used by the Geolocator and how they map to the Android priorities:

Geolocator Android
LocationAccuracy.lowest PRIORITY_PASSIVE
LocationAccuracy.low PRIORITY_LOW_POWER
LocationAccuracy.medium PRIORITY_BALANCED_POWER_ACCURACY
LocationAccuracy.high PRIORITY_HIGH_ACCURACY
LocationAccuracy.best PRIORITY_HIGH_ACCURACY
LocationAccuracy.bestForNavigation PRIORITY_HIGH_ACCURACY

UPDATE (see also issue 1082 on GitHub):

The conclusion that the Android emulator doesn't support the getCurrentPosition method is incorrect. I have run the code you attached, chancing the desiredAccuracy too LocationAccuracy.high, on the Android emulator (Android Pixel 5 - API 30) and it correctly reports the configured location. Here is the output:

W/GooglePlayServicesUtil( 2212): Google Play Store is missing.
I/flutter ( 2212): Currently, the emulator's Location Services Status = true.
I/flutter ( 2212): Current Location Permission Status = LocationPermission.whileInUse.
W/GooglePlayServicesUtil( 2212): Google Play Store is missing.
I/flutter ( 2212): Latitude: 52.56731333333333, Longitude: 5.641091666666666

Here is how I used it:

  1. Started the Android emulator.
  2. Once started I configured a position using the emulator settings (see attached image, and make sure to hit the "Set Location" button).
  3. Now start running the example App.
  4. Check the console for debug information.

Configure location on Android Emulator

I did notice however that sometimes the Android emulator doesn't want to play nice and I'd have to set the location a few times before the emulator picks it up. I have experienced this only with a fresh emulator, once I have the initial location it keeps on working just fine. What also might help is to setup a route in the Android emulator settings and repeat the playback.

Also make sure the android/app/src/main/AndroidManifest.xml contains the correct permissions (ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION) as shown in this sample snippet:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.issue_1082">

   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 
   <application
        android:label="issue_1082"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

P.S. for what it is worth, I am the author and maintainer of the Geolocator package.

歌枕肩 2025-02-15 08:16:27

使用此代码来修复它:

Future<Position> _getGeoLocationPosition() async {
    bool serviceEnabled;
    LocationPermission permission;
    // Test if location services are enabled.
    serviceEnabled = await Geolocator.isLocationServiceEnabled();
    if (!serviceEnabled) {
      await Geolocator.openLocationSettings();
      return Future.error('Location services are disabled.');
    }
    permission = await Geolocator.checkPermission();
    if (permission == LocationPermission.denied) {
      permission = await Geolocator.requestPermission();
      if (permission == LocationPermission.denied) {
        print('Location permissions are denied');
        return Future.error('Location permissions are denied');
      }
    }
    if (permission == LocationPermission.deniedForever) {
      // Permissions are denied forever, handle appropriately.
      print('Location permissions are permanently denied, we cannot request permissions.');
      return Future.error(
          'Location permissions are permanently denied, we cannot request permissions.');
    }
    // When we reach here, permissions are granted and we can
    // continue accessing the position of the device.
    return await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  }

结果:

Position position = await _getGeoLocationPosition();

Use this code for fix it :

Future<Position> _getGeoLocationPosition() async {
    bool serviceEnabled;
    LocationPermission permission;
    // Test if location services are enabled.
    serviceEnabled = await Geolocator.isLocationServiceEnabled();
    if (!serviceEnabled) {
      await Geolocator.openLocationSettings();
      return Future.error('Location services are disabled.');
    }
    permission = await Geolocator.checkPermission();
    if (permission == LocationPermission.denied) {
      permission = await Geolocator.requestPermission();
      if (permission == LocationPermission.denied) {
        print('Location permissions are denied');
        return Future.error('Location permissions are denied');
      }
    }
    if (permission == LocationPermission.deniedForever) {
      // Permissions are denied forever, handle appropriately.
      print('Location permissions are permanently denied, we cannot request permissions.');
      return Future.error(
          'Location permissions are permanently denied, we cannot request permissions.');
    }
    // When we reach here, permissions are granted and we can
    // continue accessing the position of the device.
    return await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  }

Result :

Position position = await _getGeoLocationPosition();
桃气十足 2025-02-15 08:16:27

我找到了一个解决方案和合理的解释,说明为什么 Current-lot 数据将不是通过 geolocator 在使用

  • Android的模拟器

时检索

操作 是因为Android模拟器不是真实的设备,并且缺乏在真实Android设备中发现的功能水平; Android模拟器不能接受地理层面的电流位置函数。

但是,Android模拟器确实接受Geolocator的 lastnonnolocation 函数,并且将通过其最后一个知名度函数注意模拟器位置设置中设置的位置并确认。

每个使用 geolocator 依靠 android仿真器:)

飞镖代码示例示例

import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

void main() {
  runApp(ScreenView());
}

class ScreenView extends StatefulWidget {
  double? latitude;
  double? longitude;

  ScreenView({this.latitude, this.longitude});

  void lastKnownPosition() async {
    await locationServicesStatus();
    await checkLocationPermissions();
    try {
      Position? position = await Geolocator.getLastKnownPosition();
      print(position);
    } catch (e) {
      print(e);
    }
  }

  void locationHereIs() async {
    await locationServicesStatus();
    await checkLocationPermissions();
    try {
      Position position = await Geolocator.getCurrentPosition(
              desiredAccuracy: LocationAccuracy.low)
          .timeout(Duration(seconds: 28));
      print(position);
    } catch (e) {
      print(e);
    }
  }

  Future<void> checkLocationPermissions() async {
    LocationPermission permission = await Geolocator.requestPermission();
    print('Current Location Permission Status = $permission.');
  }

  void checkLocationSettings() async {
    await Geolocator.openLocationSettings();
  }

  Future<void> locationServicesStatus() async {
    bool isLocationServiceEnabled = await Geolocator.isLocationServiceEnabled();
    print(
        'Currently, the emulator\'s Location Services Status = $isLocationServiceEnabled.');
  }

  @override
  State<ScreenView> createState() => _ScreenViewState();
}

class _ScreenViewState extends State<ScreenView> {
  @override
  void initState() {
    ScreenView().lastKnownPosition();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Debug service listening on ws://127.0.0.1:52586/aA04hHZ7dIg=/ws
Syncing files to device sdk gphone64 x86 64...
I/flutter (11353): Currently, the emulator's Location Services Status = true.
D/CompatibilityChangeReporter(11353): Compat change id reported: 78294732; UID 10149; state: ENABLED
I/flutter (11353): Current Location Permission Status = LocationPermission.whileInUse.
I/flutter (11353): Latitude: 37.333333333333336, Longitude: -121.89206891099967

我相信这一发现可以帮助 每个人。结论:人们怀疑地理定位套件是有缺陷的而没有解释的。上面的显示和解释说,地理定位器与Android模拟器效果很好,并且应该仍然是Android开发人员的最爱。

I have found a solution and a reasonable explanation for why current-position data will not be retrieved by geolocator when operating with

  • android's emulator

:

The reason is because the android emulator is not a real device and lacks the level of functionality found within real android devices; android emulator cannot accept geolocator's current-position function.

Android emulator does accept geolocator's lastKnownLocation function though, and a location set within the emulator's location settings will be noticed and confirmed by geolocator via its lastKnownLocation function.

I trust that this finding helps everyone working with geolocator relying on the android emulator : )

Dart code example:

import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

void main() {
  runApp(ScreenView());
}

class ScreenView extends StatefulWidget {
  double? latitude;
  double? longitude;

  ScreenView({this.latitude, this.longitude});

  void lastKnownPosition() async {
    await locationServicesStatus();
    await checkLocationPermissions();
    try {
      Position? position = await Geolocator.getLastKnownPosition();
      print(position);
    } catch (e) {
      print(e);
    }
  }

  void locationHereIs() async {
    await locationServicesStatus();
    await checkLocationPermissions();
    try {
      Position position = await Geolocator.getCurrentPosition(
              desiredAccuracy: LocationAccuracy.low)
          .timeout(Duration(seconds: 28));
      print(position);
    } catch (e) {
      print(e);
    }
  }

  Future<void> checkLocationPermissions() async {
    LocationPermission permission = await Geolocator.requestPermission();
    print('Current Location Permission Status = $permission.');
  }

  void checkLocationSettings() async {
    await Geolocator.openLocationSettings();
  }

  Future<void> locationServicesStatus() async {
    bool isLocationServiceEnabled = await Geolocator.isLocationServiceEnabled();
    print(
        'Currently, the emulator\'s Location Services Status = $isLocationServiceEnabled.');
  }

  @override
  State<ScreenView> createState() => _ScreenViewState();
}

class _ScreenViewState extends State<ScreenView> {
  @override
  void initState() {
    ScreenView().lastKnownPosition();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

Console output with lastKnownLocation:

✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Debug service listening on ws://127.0.0.1:52586/aA04hHZ7dIg=/ws
Syncing files to device sdk gphone64 x86 64...
I/flutter (11353): Currently, the emulator's Location Services Status = true.
D/CompatibilityChangeReporter(11353): Compat change id reported: 78294732; UID 10149; state: ENABLED
I/flutter (11353): Current Location Permission Status = LocationPermission.whileInUse.
I/flutter (11353): Latitude: 37.333333333333336, Longitude: -121.89206891099967

Conclusion: there has been a suspicion that the geolocator package is flawed without explanation. The above shows and explains that geolocator works fine with android emulator and should remain a favourite of android developers.

内心旳酸楚 2025-02-15 08:16:27

地球启动器8.2.1我不知道,但是API 28 PIE模拟器为何有效,但示例“设置位置”按钮 - 对我来说,对仿真器API版本不起作用29 30 31
- &gt;环形
D/FlutterGeolostotor(26734):将地理定位器附加到活动
D/FlutterGeolosotator(26808):将地理定位器附加到活动上。
我将在API模拟器28 PIE中工作。也许这会帮助某人。

geolocator 8.2.1 I do not know but why the API 28 Pie emulator works, but example the "Set Location" button - for me does not work on emulator API version 29 30 31
--> loop
D/FlutterGeolocator(26734): Attaching Geolocator to activity
D/FlutterGeolocator(26808): Attaching Geolocator to activity.
I will work in the API emulator 28 Pie. maybe this will help someone.

浅紫色的梦幻 2025-02-15 08:16:27

除@mauritsvanbeusekom's 答案纬度/经度,甚至只是旋转导航指南针。

在我的情况下,尽管由于某种技术故障,GPS仍在使用,但我无法以准确性最佳来检索位置,并且仅通过改变纬度和经度,但我解决了问题。

In addition to @MauritsvanBeusekom 's answer people who are using Genymotion emulators should try to turn on the GPS and change the default values of latitude/longitude or even just rotate the navigation compass.

In my case although the GPS was on due to some technical glitch I was unable to retrieve the location with accuracy best and just by altering the latitude and longitude, I solved my issue.
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文