gpt4 book ai didi

java - 无法解析符号 'GeoPoint'

转载 作者:行者123 更新时间:2023-11-29 22:53:47 24 4
gpt4 key购买 nike

不确定发生了什么,但是当我尝试调用 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());
}
}
});
}

最佳答案

尝试使用 LatLng 而不是 GeoPoint:

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

关于java - 无法解析符号 'GeoPoint',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57625647/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com