[英]Using @JavascriptInterface send value to assets/map.html
I get Latitude,Longitude and send it to map.html However I try two ways. 我得到纬度,经度并将其发送到map.html。但是我尝试了两种方法。
First.I give two value type is "double" and this way is success 首先,我给两个值类型是“ double”,这样成功
@JavascriptInterface
public double getLatitude() {
return 25.03314;
}
@JavascriptInterface
public double getLongitude() {
return 121.5637343;
}
but next,I use onLocationChanged(Location location) in activity get my Latitude,Longitude 但是接下来,我在活动中使用onLocationChanged(Location location)获取我的纬度,经度
and send , but this way is fail. 然后发送,但是这种方式失败了。 I don't know where have error because haven't error message 我不知道哪里有错误,因为没有错误消息
so if I want react the function what I to do ? 因此,如果我想对功能进行反应,该怎么办?
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
getLatitude(location.getLatitude());
getLongitude(location.getLongitude());
}
@JavascriptInterface
public double getLatitude(double lat) {
Log.e("TAG",String.valueOf(lat));
return lat;
}
@JavascriptInterface
public double getLongitude(double lon) {
Log.e("TAG",String.valueOf(lon));
return lon;
}
double lat = 0.0,lat=0.0;
change to 改成
static double lat = 0.0,lat=0.0;
and 和
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
lat = location.getLatitude();
lon = location.getLongitude();
}
@JavascriptInterface
public double getLatitude() {
Log.e("TAG",String.valueOf(lat));
return lat;
}
@JavascriptInterface
public double getLongitude() {
Log.e("TAG",String.valueOf(lon));
return lon;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.