开发者

Does specifying criteria switch the location provider in Android?

I want that the application should switch between GPS_PROVIDER and NETWORK_PROVIDER automatically. At present, I specify the providers in the program, so, if I specify criteria and set the locationlistener with that, then will it switch automatically to GPS_PROVIDER automatically whenever available?

For example, when the app started and 开发者_开发百科listener was set at that time GPS_PROVIDER was not available or was not receiving location updates, but after some time it started receiving location updates then will the app automatically get the data from GPS_PROVIDER?

Otherwise, what is the best way of switching between the providers?

Just to add one more thing, the application will call requestLocationUpdates() only once in the app.


you can modify your onLocationChanged method like,

   @Override
public void onLocationChanged(Location location) {

    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){   
    Log.e("OnLocationChange Latitude",""+location.getLatitude());
            Log.e("OnLocationChange Longitude",""+location.getLongitude());

}
}

now these lat,long are given by gps provider. and for your other question I think you tested the application on emulator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜