Fusion Location Provider API 声称位置更新在室内不起作用 [英] Location updates not working indoors as claimed by Fusion Location Provider APIs

查看:27
本文介绍了Fusion Location Provider API 声称位置更新在室内不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

位置更新在 Fusion Location Provider API 声称的室内不起作用.

Location updates not working indoors as claimed by Fusion Location Provider APIs.

发生了什么:

  1. 我尝试在我的 Android 应用中使用 LocationClient 实现最新的位置 API 以获取位置更新.
  2. 我在户外测试时,我的 Android 应用运行良好,没有任何问题.
  3. 但在室内(任何建筑物内)进行测试时,不会发生位置更新.
  1. I tried implementing the latest location API to get location updates using LocationClient in my Android App.
  2. My android app works fine with out any issue while I am testing outdoor.
  3. But when testing indoors (inside any building), then no location updates are happening.

预期行为:

根据新的 API,我希望在我在室内时获得建筑物周围的一些估计位置(因为 GPS 无法找到准确位置的卫星信号).

As per the new APIs, I am expecting to get some estimated location around the building while I am indoors (as GPS do not find the satellite signal for accurate location).

我发现最新的谷歌地图安卓应用可以在室内使用估计位置正常工作.

I see that latest Google Maps android app works fine indoors with estimated location.

问题:

我还需要注意什么,使用新的位置 API 来获取室内位置更新(不需要准确的位置,低准确度也可以).

What else do I have to take care using new location APIs to get the location update indoors (accurate location is not required, low accuracy is also fine).

我正在使用 Android 4.2.2 版本的 API 实现 Android 应用程序.我正在 HTC One X (OS v 4.1.1) 上测试

I am implementing the Android App using Android 4.2.2 version APIs. I am testing on HTC One X (OS v 4.1.1)

以下是我用于使用新 API 获取位置更新的 android 代码:

第一步:

mLocationClient = new LocationClient(this, this, this);

步骤 2:

// Create the LocationRequest object
mLocationRequest = LocationRequest.create();
// Use high accuracy
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
// Set the update interval to 5 seconds
mLocationRequest.setInterval(UPDATE_INTERVAL);
// Set the fastest update interval to 1 second
mLocationRequest.setFastestInterval(FASTEST_INTERVAL);

Step3:在 onStart() 方法中 - 添加下面的行:

Step3: inside onStart() method - below line is added:

// Connect the client.
mLocationClient.connect();

Step4:在 onConnected() 方法中 - 添加以下行:

Step4: inside onConnected() method - below line is added:

mLocationClient.requestLocationUpdates(mLocationRequest, this);

Step5:在 onLocationChanged() 方法内部 - 监听位置更新.测试内部时不调用此方法.只有在找到 GPS 信号时才会调用此方法.

Step5: inside onLocationChanged() method - listening for location updates. This method is not called when testing insides. This method is getting called only when GPS signal is found.

double lat = location.getLatitude();
double lng = location.getLongitude();

最终在 Android Manifest 中添加以下权限:

Finally added below permissions in Android Manifest:

 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

推荐答案

在 HTC One X (4.1.1) 上进行了长时间的测试和调试后,我决定在任何其他手机型号上尝试相同的测试用例.幸运的是,在使用我朋友的三星 S3 (4.1.1) 进行测试时,我的应用程序也可以在室内运行.在同一时间和位置,当我使用 HTC One X 进行测试时,我没有在室内定位.两部手机都设置了相同的设置(WiFi/GPS/移动网络均已启用).

After long testing and debugging on HTC One X (4.1.1), I decided to try same test cases on any other phone model. Luckily my app worked indoors too when testing with my friend's Samsung S3 (4.1.1). At same time and location, when I tested with my HTC One X, I do not get location indoors. Both phones are set with same settings (WiFi/GPS/Mobile network all enabled).

为了确认这是特定设备的问题,我使用我的应用程序在建筑物内的不同角落进行了许多测试,我在 HTC 的所有室内位置都看到了相同的问题(但在相同的位置 S3 获取室内位置).

To confirm this is an issue with specific device, I performed many tests inside the building at different corners using my app and I see the same issue on my HTC at all indoor locations (but at same locations S3 gets the indoor location).

这篇关于Fusion Location Provider API 声称位置更新在室内不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆