var Thread = window.plus.android.importClass("java.lang.Thread");
var Runnable = window.plus.android.implements( "java.lang.Runnable", {
run:function () {
window.plus.geolocation.watchPosition(function (position) {
var str = "";
str += "地址:" + position.addresses + "\n"; //获取地址信息
str += "坐标类型:" + position.coordsType + "\n";
var codns = position.coords; //获取地理坐标信息;
var lat = codns.latitude; //获取到当前位置的纬度;
str += "纬度:" + lat + "\n";
var longt = codns.longitude; //获取到当前位置的经度
str += "经度:" + longt + "\n";
str += "时间:" + that.$formatDate(new Date(), 'hh:mm:ss') + "\n";
that.$store.dispatch('setLocation', `${codns.latitude},${codns.longitude}`);
that.$store.state.mobile && uploadDeliveryLocation({
deliveryLocation: that.$store.state.location,
deliveryMobile: that.$store.state.mobile
}).then((result) => {
console.log('成功',result);
}).catch((err) => {
console.log('失败',err);
});
console.log(str);
}, function (e) {
that.$alert(e.message);
console.log("监听位置变化信息失败:" + e.message);
}, {
maximumAge: 60000,
provider: "baidu",
geocode: true,
// enableHighAccuracy:true
});
}
})
that.thread = new Thread(Runnable);
that.thread.start();
that.thread.setDaemon(true);
前端程序员一枚
- 发布:2019-08-24 14:19
- 更新:2019-12-26 16:18
- 阅读:1451
安卓app后台运行或锁屏之后,一段时间后这个app发送的http都超时了
分类:5+ SDK