android - 获取用户位置的时间太长?

标签 android gps

我是 android 开发的初学者。 问题是代码需要几分钟才能获取用户位置,所以我该如何解决这个问题? 请帮助我

LocationListener locationListener = new LocationListener() {
        public void onLocationChanged(Location location) {

        Toast.makeText(getBaseContext(), 
               "Location changed : Lat: " + location.getLatitude() + 
             " Lng: " + location .getLongitude(), 
               Toast.LENGTH_SHORT).show();
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {}

        public void onProviderEnabled(String provider) {}

        public void onProviderDisabled(String provider) {}
      };


        lm.requestLocationUpdates(
            LocationManager.GPS_PROVIDER, 
            0, 
            0, 
            locationListener);

最佳答案

GPS 启动总是很慢,而且在室内不起作用。您可能想阅读 this :

I'm a big fan of location-based apps, but not their seemingly-inevitable startup latency.

Whether it's finding a place to eat or searching for the nearest Boris Bike, I find the delay while waiting for the GPS to get a fix, and then for the results list to populate, to be interminable. Once I’m in a venue and ready to get some tips, check-in, or review the food, I’m frequently thwarted by a lack of data connection.

关于android - 获取用户位置的时间太长?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7213966/

相关文章:

java - 执行doInBackground()时出错,不知道是什么问题

python - 单击“提交”按钮后使用 Python 获取新 URL

java - GPS 和网络定位 android

java - 如果我使用Android服务,为什么我的应用程序会关闭?

android - 我怎样才能在 Activity 中获得recevier实例(在AndroidManifest.xml中注册)

ios - 通过地址或GPS坐标获取最近的商家名称/类型

java - 如何在android中每1分钟移动一次获得不同的纬度和经度?

android - 如何从我的 GPS 坐标中获取附近的位置?

java - 如何获取父节点的值作为字符串?

android - Robolectric 3.0 在 DefaultPackageManager.getActivityInfo() 上抛出 Nullpointer