Android:当我启动相机和 SurfaceView 时,某些手机上的 GPS 信号强度会丢失

发布于 2024-11-29 21:20:51 字数 1530 浏览 0 评论 0原文

我正在开发一个可以拍摄 GPS 编码照片的应用程序。

当我不运行相机时,我能够获得大约 15 - 20 米精度的 GPS 信号强度,并且范围内至少有 3 颗卫星,有时有 5 - 7 颗卫星。

然而,当我启动一个同时显示连接了相机的 SurfaceView 和 GPS 代码的 Activity 时,我的准确度会大幅下降(> 100 米),但仅限于某些手机。

它无法运行的手机:

  1. Droid Incredible 2
  2. HTC Wildfire
  3. HTC Inspire

它可以运行的手机:

  1. Atrix
  2. Galaxy Tab
  3. Motorolla Droid (原版)

那么,我的问题是,为什么会发生这种情况?当然,我该如何解决它?

这是我用来启动 GPS 的代码

try{
    locator = new GeoLocator(this);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.addGpsStatusListener(new GPSStatusManager(locationManager));
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
    bestProvider = locationManager.getBestProvider(criteria, true);
    Bundle bundle = new Bundle();
    //I copied the next two lines out of some tutorial hoping that they would help boost my gps, but I'm really not sure what they do
    boolean xtraInjection=locationManager.sendExtraCommand(LocationManager.GPS_PROVIDER,
                                          "force_xtra_injection",bundle);
    boolean timeInjection=locationManager.sendExtraCommand(LocationManager.GPS_PROVIDER,
                                          "force_time_injection",bundle);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0.0f, locator);
}catch(Exception e){}

I am working on an app that takes GPS encoded pictures.

I am able to get about 15 - 20 meters accuracy GPS signal strength when I am not running the camera, and have at least 3 satellites in range, sometimes 5 - 7 satellites.

However, when I start up an activity that both displays the SurfaceView with the Camera hooked up to it AND the GPS code, my accuracy goes way down (> 100 meters), but only on some phones.

Phones that it does not work on:

  1. Droid Incredible 2
  2. HTC Wildfire
  3. HTC Inspire

Phones that it does work on:

  1. Atrix
  2. Galaxy Tab
  3. Motorolla Droid (The original)

So, my questions are, why would this happen? And of course, how can I fix it?

Here is my code that I am using to stoke up the GPS

try{
    locator = new GeoLocator(this);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.addGpsStatusListener(new GPSStatusManager(locationManager));
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
    bestProvider = locationManager.getBestProvider(criteria, true);
    Bundle bundle = new Bundle();
    //I copied the next two lines out of some tutorial hoping that they would help boost my gps, but I'm really not sure what they do
    boolean xtraInjection=locationManager.sendExtraCommand(LocationManager.GPS_PROVIDER,
                                          "force_xtra_injection",bundle);
    boolean timeInjection=locationManager.sendExtraCommand(LocationManager.GPS_PROVIDER,
                                          "force_time_injection",bundle);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0.0f, locator);
}catch(Exception e){}

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

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

发布评论

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

评论(2

似梦非梦 2024-12-06 21:20:51

在这里完成猜测,但尝试将这一行更改

criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);

为:

criteria.setPowerRequirement(Criteria.POWER_HIGH);

理论:通过不指定 GPS 的高功率要求,您将允许操作系统以低功耗模式运行 GPS,每当您转动时都会这样做其他耗电配件上。当 GPS 在低功耗模式下运行时,精度会降低。

Complete guess here, but try changing this line:

criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);

to this:

criteria.setPowerRequirement(Criteria.POWER_HIGH);

Theory: by not specifying high power requirement for the GPS, you're allowing the OS to run the GPS in a less-power-consumptive mode, which it does whenever you turn on other power-consuming accessories. When the GPS is run in low-power mode, that will make it less accurate.

征﹌骨岁月お 2024-12-06 21:20:51

Galaxy Gio GTS5660 (Android 2.3.6) 和 LG5 E610 也是如此。
它实际上是此错误的一个实例,看起来最有可能是硬件问题:http://code.google.com/p/android/issues/detail?id=20098

Same here with a galaxy Gio GTS5660 (Android 2.3.6) and a LG5 E610.
It is actually an instance of this bug, which looks most likely to be a hardware issue: http://code.google.com/p/android/issues/detail?id=20098

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