前端程序员一枚
前端程序员一枚
  • 发布:2019-08-24 14:19
  • 更新:2019-12-26 16:18
  • 阅读:1336

安卓app后台运行或锁屏之后,一段时间后这个app发送的http都超时了

分类:5+ SDK
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 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com

大神,请问您这个问题解决了么? 我遇到了相同的问题

该问题目前已经被锁定, 无法添加新回复