Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 用于测试目的的火灾位置事件_Android_Geolocation_Titanium - Fatal编程技术网

Android 用于测试目的的火灾位置事件

Android 用于测试目的的火灾位置事件,android,geolocation,titanium,Android,Geolocation,Titanium,我正在测试Android的地理定位功能 我需要在几米以外的地方发动这场比赛 另一方面,在iOS上,此函数在我启动应用程序时启动, 我的iphone是4G,但android使用Wifi,这可能是原因 有没有什么好的方法可以启动这个函数进行测试 Ti.Geolocation.addEventListener('location', function(e) { if (e.error) { } else { Ti.API.info(e.coo

我正在测试Android的地理定位功能

我需要在几米以外的地方发动这场比赛

另一方面,在iOS上,此函数在我启动应用程序时启动, 我的iphone是4G,但android使用Wifi,这可能是原因

有没有什么好的方法可以启动这个函数进行测试

Ti.Geolocation.addEventListener('location', function(e) {
   if (e.error) {       
        } else {
            Ti.API.info(e.coords);
    }
});  

在你身上,我会这样做:

var locationListener = function(e) {
   if (e.error) {       
        } else {
            Ti.API.info(e.coords);
    }
};
Ti.Geolocation.addEventListener('location', locationListener); 
Ti.App.addEventListener('testLocation', locationListener);
我会在对您更有利的时候启动testLocation:

Ti.App.fireEvent('testLocation', {success: true, coords: {latitude: 0, longitude: 0}});

显然,在addEventListener设置Ti.geolocation.Android之前,请使用所需的所有属性设置参数,不要忘记从Ti.App中删除testLocation事件侦听器。

    Ti.Geolocation.Android.manualMode = true;
    Ti.Geolocation.Android.addLocationProvider(Ti.Geolocation.Android.createLocationProvider({
        name : Ti.Geolocation.PROVIDER_GPS,
        minUpdateDistance : 1, // 1 metre 
        minUpdateTime: 1 // one per second
    }));
    Ti.Geolocation.Android.addLocationRule(Ti.Geolocation.Android.createLocationRule({
        provider : Ti.Geolocation.PROVIDER_GPS,
        accuracy : 50, // Updates should be accurate to 50m
        maxAge: 1000, // Updates should be no older than 1 seconde 
        minAge: 200, // But  no more frequent than 5 per seconds
    }));