在许多情况下,intent 替代方案是正确的,但是如果您真的想模拟真实用户拨打号码,您可以使用从自动生成的稍微编辑的culebra脚本 来添加方法和其他小东西:dialNumber
#! /usr/local/bin/shebang monkeyrunner -plugin $AVC_HOME/bin/androidviewclient-$AVC_VERSION.jar @!
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013 Diego Torres Milano
Created on 2013-05-15 by Culebra v0.9.8
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''
import re
import sys
import os
from com.dtmilano.android.viewclient import ViewClient
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
def dialNumber(number):
print "dialing", number
digits = [zero, one, two, three, four, five, six, seven, eight, nine]
for d in number:
if d in ['-', ' ']:
continue
digits[int(d)].touch()
vc.sleep(0.5)
dial.touch()
device, serialno = ViewClient.connectToDeviceOrExit()
device.startActivity(component='com.android.contacts/com.android.contacts.activities.DialtactsActivity')
vc = ViewClient(device, serialno, autodump=False)
vc.dump(window='-1')
back = vc.findViewWithContentDescriptionOrRaise('backspace')
one = vc.findViewWithContentDescriptionOrRaise('one')
two = vc.findViewWithContentDescriptionOrRaise('two')
three = vc.findViewWithContentDescriptionOrRaise('three')
four = vc.findViewWithContentDescriptionOrRaise('four')
five = vc.findViewWithContentDescriptionOrRaise('five')
six = vc.findViewWithContentDescriptionOrRaise('six')
seven = vc.findViewWithContentDescriptionOrRaise('seven')
eight = vc.findViewWithContentDescriptionOrRaise('eight')
nine = vc.findViewWithContentDescriptionOrRaise('nine')
star = vc.findViewWithContentDescriptionOrRaise('star')
zero = vc.findViewWithContentDescriptionOrRaise('zero')
pound = vc.findViewWithContentDescriptionOrRaise('pound')
dial = vc.findViewWithContentDescriptionOrRaise('dial')
search = vc.findViewWithContentDescriptionOrRaise('search')
moreOptions = vc.findViewWithContentDescriptionOrRaise('More options')
dialNumber("800-555-1234")