无法解析符号“ GeoPoint”

时间:2019-08-23 11:41:34

标签: java android geopoints

不确定发生了什么,但是当我尝试致电GeoPoint以获取设备当前的经度和纬度时,我收到通知“无法解析符号'GeoPoint'。不太清楚发生了什么事情

private void getLastKnownLocation() {
    Log.d(TAG, "getLastKnownLocation: called.");

    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        return;
    }
    mFusedLocationClient.getLastLocation().addOnCompleteListener(new OnCompleteListener<android.location.Location>() {
        @Override
        public void onComplete(@NonNull Task<android.location.Location> task) {
            if (task.isSuccessful()) {
                Location location = task.getResult();
                GeoPoint geoPoint = new GeoPoint(location.getLatitude(), location.getLongitude());
                Log.d(TAG, "onComplete: latitude: " + geoPoint.getLatitude());
                Log.d(TAG, "onComplete: longitude: " + geoPoint.getLongitude());
            }
        }
    });
}

1 个答案:

答案 0 :(得分:1)

尝试使用LatLng代替GeoPoint:

LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());