Java 使用2倍的intValue时,无法在Android Studio中解析地质点构造函数
在以下创建地质点的过程中 latitude.intValue() 及 longitude.intValue() 在Android Studio中以红色下划线显示Java 使用2倍的intValue时,无法在Android Studio中解析地质点构造函数,java,android,Java,Android,在以下创建地质点的过程中 latitude.intValue() 及 longitude.intValue() 在Android Studio中以红色下划线显示 Double latitude = location.getLatitude()* 1E6; Double longitude = location.getLongitude() * 1E6; Barcode.GeoPoint point = new Barcode.GeoPoint(latitude.intValue(),lo
Double latitude = location.getLatitude()* 1E6;
Double longitude = location.getLongitude() * 1E6;
Barcode.GeoPoint point = new Barcode.GeoPoint(latitude.intValue(),longitude.intValue());
有人能告诉我我做错了什么吗
PS:这些是我的进口货
import android.app.DialogFragment;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.location.Location;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.vision.barcode.Barcode.GeoPoint;
import java.util.ArrayList;
import java.util.List;
试着这样做:
Barcode.GeoPoint point = new Barcode.GeoPoint(Integer.valueOf(latitude),Integer.valueOf(longitude);
public static GeoPoint coordinatesToGeoPoint(double[] coords) {
if (coords.length > 2) {
return null;
}
if (coords[0] == Double.NaN || coords[1] == Double.NaN) {
return null;
}
final int latitude = (int) (coords[0] * 1E6);
final int longitude = (int) (coords[1] * 1E6);
return new GeoPoint(latitude, longitude);
}
或者您可以这样使用:
Barcode.GeoPoint point = new Barcode.GeoPoint(Integer.valueOf(latitude),Integer.valueOf(longitude);
public static GeoPoint coordinatesToGeoPoint(double[] coords) {
if (coords.length > 2) {
return null;
}
if (coords[0] == Double.NaN || coords[1] == Double.NaN) {
return null;
}
final int latitude = (int) (coords[0] * 1E6);
final int longitude = (int) (coords[1] * 1E6);
return new GeoPoint(latitude, longitude);
}
另一个简单的方法是:
地质点坐标以微度为单位(度*1e6)
试着这样做:
Barcode.GeoPoint point = new Barcode.GeoPoint(Integer.valueOf(latitude),Integer.valueOf(longitude);
public static GeoPoint coordinatesToGeoPoint(double[] coords) {
if (coords.length > 2) {
return null;
}
if (coords[0] == Double.NaN || coords[1] == Double.NaN) {
return null;
}
final int latitude = (int) (coords[0] * 1E6);
final int longitude = (int) (coords[1] * 1E6);
return new GeoPoint(latitude, longitude);
}
或者您可以这样使用:
Barcode.GeoPoint point = new Barcode.GeoPoint(Integer.valueOf(latitude),Integer.valueOf(longitude);
public static GeoPoint coordinatesToGeoPoint(double[] coords) {
if (coords.length > 2) {
return null;
}
if (coords[0] == Double.NaN || coords[1] == Double.NaN) {
return null;
}
final int latitude = (int) (coords[0] * 1E6);
final int longitude = (int) (coords[1] * 1E6);
return new GeoPoint(latitude, longitude);
}
另一个简单的方法是:
地质点坐标以微度为单位(度*1e6)
是否包含所需的库(如果有),例如,如果使用AppCompat库,则应使用compat库中的方法和类是否包含所需的库(如果有),例如,如果使用AppCompat库,您应该使用compat Library中的方法和类我尝试了所有方法,这一种:
Barcode.GeoPoint newPoint=new Barcode.GeoPoint((int)(loc.getLatitude()*1E6),(int)(loc.getLongitude()*1E6))代码>但我仍然有同样的问题。我尝试在这里应用的GeoPoint Synthax是否已弃用?您正在使用哪个库?我想你们应该遵循@Cool Guy commentother-wise used Geofence…,这是我找到的最好的例子,我尝试了所有的方法,这一个:Barcode.GeoPoint newPoint=new Barcode.GeoPoint((int)(loc.getLatitude()*1E6),(int)(loc.getLongitude()*1E6))代码>但我仍然有同样的问题。我尝试在这里应用的GeoPoint Synthax是否已弃用?您正在使用哪个库?我认为你们应该跟随@Cool Guy commentother-wise-used geopfence…,这是我发现的最好的例子