切换到无线在Android模拟器

切换到无线在Android模拟器

本文介绍了如何禁用/启用网络,切换到无线在Android模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个推送通知库为Android( http://deaconproject.org/ )需要,如果要采取行动网络连通被中断或改变 - 即,它需要重新发起服务器连接或暂停其操作直到网络连接可用。这似乎采用和Android的BroadcastReceiver的android.net.ConnectivityManager.CONNECTIVITY_ACTION。

I'm working on a Push Notifications library for Android (http://deaconproject.org/) that needs to take action if network connectivity is interrupted or changed - namely, it needs to re-initiate a server connection or pause its operation until network connectivity is available. This seems to work fine using and Android BroadcastReceiver for "android.net.ConnectivityManager.CONNECTIVITY_ACTION".

我的问题是在测试库 - 我想自动测试库的响应网络连接中断,或者从3G到无线网络的过渡,各种配置的条件下。问题是,我不想坐在模拟器和按F8一整天。

My problem is in testing the library - I would like to automatically test the library's response to a broken network connection, or a transition from 3G to WiFi, under various configuration conditions. The problem is, I don't want to sit with the emulator and hit F8 all day.

有没有一种方法以编程方式从一个JUnit测试操作Android上的网络连接,而不诉诸切换飞行模式?我已经尝试过发出命令通过控制台模拟器,操纵GSM模式等,但同时在显示屏上的手机状态改变,互联网连接保持了起来。

Is there a way to programmatically manipulate network connections on Android from within a jUnit test without resorting to toggling Airplane Mode? I've already tried issuing commands to the emulator via the console, manipulating the GSM mode, etc, but while the phone state changes on the display, the Internet connection remains up.

推荐答案

右键中的工程资源管理器面板中单击项目,选择运行方式,然后运行配置。

Right click on project in the "Project Explorer" panel, chose "Run As" then "Run Configurations".

在显示模态窗口左侧选择Android应用程序,并在右侧的同一个窗口中,选择选项卡的目标。

On the left side of the modally shown window chose "Android Application" and on the right side of the same window, chose tab "Target".

在窗口底部的模拟器启动参数一节中,你有关于互联网连接的选项过多。

At the bottom of the window, in the "Emulator Launch Parameters" section you have plethora of options regarding internet connectivity.

我希望这有助于。

伊戈尔

这篇关于如何禁用/启用网络,切换到无线在Android模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 00:29