2016-06-17 7 views
-2

私は現在の場所を取得しようとしています。 onCreateメソッドでAndroid LocationListener- requestLocationUpdates

public LocationListener mLocationListener = new LocationListener() { 
     @Override 
     public void onLocationChanged(final Location location) { 
      // Getting latitude of the current location 
      double latitude = location.getLatitude(); 

      // Getting longitude of the current location 
      double longitude = location.getLongitude(); 

      // Creating a LatLng object for the current location 
      myLocation = new LatLng(latitude, longitude); 
     } 
    }; 

のIがLocationManagerにrequestLocatonUpatesをCALしよう:まず、私はLocationListener作成

mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); 
     mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,500f,mLocationListener); 

をしかし、私はエラーを取得する:

は、(java.langStringの方法requestLocationUpdatesを解決できません。 long、float、com.google.android.gms.location.LocationListener)

+0

google.android.gms.location.LocationListenerではなく、android.location.LocationListenerを渡すようにしてください。 – Blackkara

答えて

0

requestLocationUpdatesはFusedLocationAPiで提供されるメソッドです。 LocationServices.FusedLocationApi.requestLocationUpdatesメソッドを使用する必要があります。 したがって、googleApiClientとロケーションリクエストを作成する必要があります。 あなたはここにそれを見つけることができます:https://developer.android.com/training/location/index.html

関連する問題