I get Latitude,Longitude and send it to map.html However I try two ways.
First.I give two value type is "double" and this way is success
@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
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.