-1

我在我的设备上使用 Jelly Bean 4.2.2 并尝试使用 Monkeyrunner 脚本拨打电话。我正在使用下面的代码,它在 ICS 上运行得很好,但在 JB 中,一旦打开按键拨号器屏幕,它就不会在编辑文本框中输入电话号码.. 有人遇到过这个问题吗?

device.startActivity(component='com.android.contacts/com.android.contacts.activities.DialtactsActivity')

device.type("8888888888")

BR斯里尼

4

1 回答 1

0

在许多情况下,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")
于 2013-05-15T17:55:09.113 回答