小编Raj*_*a45的帖子

Android中的融合位置提供程序

我正在使用Fused Location Provider开发应用程序.我有个疑问.为了定期获取位置,它使用requestLocationUpdates().但是从哪个来源获取WIFI或GPS或网络的位置.在我的应用程序中,仅当WiFi处于开启状态时,它才会定期获取位置.当WiFi处于关闭状态时,它无法获得该位置(它应该从GPS或网络的其他来源获得位置.但它永远不会获得位置.或者我必须为GPS和网络编写听众).我不知道是什么问题.谁能帮我.

并且,它是否仅适用于所有提供商(Wifi,GPS,网络)或其他.

public void checkPlay(){

  int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (resp == ConnectionResult.SUCCESS) {
        locationClient = new LocationClient(this, this, this);
        locationClient.connect();
    } else {
        Toast.makeText(this, "Google Play Service Error " + resp,
                Toast.LENGTH_LONG).show();

    }
 }


public void onConnected(Bundle arg0) {
    // TODO Auto-generated method stub


    if (locationClient != null && locationClient.isConnected()) {

        locationRequest = LocationRequest.create();
        locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        locationRequest.setInterval(100);
        locationClient.requestLocationUpdates(locationRequest, this);

    }
}

        public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub
    try {
        if (location != null) { …
Run Code Online (Sandbox Code Playgroud)

gps android google-maps location-provider google-maps-android-api-2

9
推荐指数
2
解决办法
1万
查看次数