English 中文(简体)
地点坐标在使用地点时不变
原标题:Location coordinates does not change when using LocationListener

I am using LocationListener on my application. However, whenever my location changes or onLocationChanged(Location location) method is executed, the coordinates of my location does not change at all. I am riding inside a car and had traveled several meters to kilometers already without my location changing. What could be the problem?

我的法典:

LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
String bestProvider = locationManager.getBestProvider(new Criteria(), true);
{LocationListener locationListener = new LocationListener()
{
    public void onLocationChanged(Location location)
    {
        //location.getLatitude(), location.getLongtitude()
        //location coordinates does not change at all everytime onLocationChanged is called even after I already move several meters or kilometers.
    }

    //...
}
locationManager.requestLocationUpdates(bestProvider, 0, 0, locationListener);
最佳回答

引言

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

你们可能利用网络提供者。 听众通常被解职。 你们可以安排听众参加活动。

不能确定由甲体确定最佳提供者的逻辑是什么。 但是,与网络供应商相比,全球定位系统总是被认为是最准确的。 但是,在通过全球定位系统锁定一个位置时,有些条件是不可能的。 当网络提供者投入使用时。

我通常创设一个简单类别,要求获得地点编码。 在职能方面,我首先要求使用全球定位系统的地点。 如果没有收到,则我等待30秒,然后请它使用网络供应商。 这样,我就能够永远确保我获得全球定位系统的价值,作为我的第一选择。

问题回答

我的猜测是,你的位置正在发生变化,但你却忽视了自由度和长足的精髓。 注:在地点变更之前和之后精度部分的最后数。

以这种方式对待你的法典

if(isInternetEnabled==true)//check for internet connection here
{
 locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,  
        locationListener);  
}
else
{
 locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,  
        locationListener);  
}

Because it happens with me that GPS_PROVIDER doesn t give quick response to location update then NETWORK_PROVIDER.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签