Is there any way to switch on wifi in monkeyrunner otherthan using the cordinates.?Can we use WifiManager api from monkeyrunner.
from开发者_如何学C android.net.wifi import WifiManger is working after copying android.jar file to tool/lib location.But how to invoke the WifiManger methods inside a android fon using monkeyrunner/monkey..??Somebody please help.
You can switch on the wi-fi by another way. Start the activity of settings and go to the "wireless & network settings" and enable it.
Following code is the start the activity of the settings:
# sets a variable with the package's internal name
package = 'com.android.settings'
# sets a variable with the name of an Activity in the package
activity = 'com.android.settings.Settings'
# sets the name of the component to start
runComponent = package + '/' + activity
setting = 'com.android.settings.Settings'
print("")
print("")
print("Start the Activity...")
# Runs the component
device.startActivity(component=runComponent)
After that by the press event use 'DOWN' and 'ENTER' KeyCode and you can enable the wi-fi...!!!
I looked into this exact issue a few months ago. It did not seem possible to me; at least easily. The best way I could find was to use startActivity to get as close to the wi-fi settings as possible, and then program in D-PAD commands until the correct field was highlighted. You may be able to use this logic to develop a small, purpose build, app that onCreate or onResume toggles wi-fi. In my case, it was not worth the amount of time this would have taken.
精彩评论