Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.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
在Travis上使用Android模拟器自动测试Geofenses_Android_Android Emulator_Travis Ci_Android Geofence - Fatal编程技术网

在Travis上使用Android模拟器自动测试Geofenses

在Travis上使用Android模拟器自动测试Geofenses,android,android-emulator,travis-ci,android-geofence,Android,Android Emulator,Travis Ci,Android Geofence,我正在尝试在我的应用程序中使用Android Geofences,并通过Travis CI测试该应用程序。在我的本地设备和本地仿真器上一切正常。但不是特拉维斯·西 事实证明,无法添加地理围栏,因为网络位置提供程序已禁用。(我收到地理围栏\u不可用错误状态) 使用Settings.Secure.getInt(this.getContentResolver(),Settings.Secure.Location\u MODE)检查我的位置设置时,只返回Location\u MODE\u传感器,这意味着

我正在尝试在我的应用程序中使用Android Geofences,并通过Travis CI测试该应用程序。在我的本地设备和本地仿真器上一切正常。但不是特拉维斯·西

事实证明,无法添加地理围栏,因为网络位置提供程序已禁用。(我收到
地理围栏\u不可用
错误状态)

使用
Settings.Secure.getInt(this.getContentResolver(),Settings.Secure.Location\u MODE)
检查我的位置设置时,只返回
Location\u MODE\u传感器
,这意味着禁用了网络位置提供程序,但根据文档,启用了GPS和其他传感器

据我所知,出于安全考虑,以编程方式启用网络位置提供程序是不可能的

如果我在本地设备和本地仿真器上的设置菜单中禁用移动网络位置,我可以从Travis CI上的仿真器中重现该行为

有没有办法在Travis上配置Emulator,使其从一开始就启用设置菜单中的移动网络位置?或者,即使网络提供商被禁用,我也可以在我的应用程序中添加地理围栏吗

这是我的特拉维斯

language: android
cache: false
sudo: false
env:
  global:
  - ADB_INSTALL_TIMEOUT=16
android:
  components:
  - build-tools-22.0.1
  - android-21
  - extra-google-google_play_services
  - extra-google-m2repository
  - extra-android-m2repository
  - addon-google_apis-google-21
  - sys-img-armeabi-v7a-addon-google_apis-google-21

before_install:
- chmod +x gradlew
- android list target
- echo no | android create avd --force -n test -t "Google Inc.:Google APIs:21"
  --abi google_apis/armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- chmod +x wait_for_emulator.sh
- ./wait_for_emulator.sh
- sleep 30

before_script:

- adb logcat &
- adb shell input keyevent 82 &
- sleep 30
- adb shell settings put secure location_providers_allowed off &
- sleep 30
- adb shell settings put secure location_providers_allowed network,gps,wifi &
- sleep 30
- adb shell input keyevent 22 &
- sleep 10
- adb shell input keyevent 23
- sleep 10



script:


- "./gradlew build connectedCheck --stacktrace --continue -PdisablePreDex"
谢谢你的帮助

更新:

经过一些研究并感谢post,我发现我可以通过这个
adb shell
命令更改设置:

settings put secure location_providers_allowed network,gps,wifi
但仍然需要用户同意。我试着接受:

input keyevent 22
input keyevent 23
这可以在我的本地设备和本地仿真器上运行,但在Travis仿真器上仍然失败。我相应地更改了附带的travis.yml,可以找到travis日志文件。毕竟,网络提供商仍然没有启用,而且在应用程序启动测试后,而不是在我通过
adb
发出启用命令时,似乎会弹出
ConfirmAlertActivity