其實(shí)和mobile的差不多。
在開(kāi)發(fā)Android程序的時(shí)候,我們往往需要處理來(lái)電或者短消息,但是在開(kāi)發(fā)過(guò)程中基本都是通過(guò)模擬器來(lái)進(jìn)行調試,那么下面我們就介紹一下如何向模擬器打電話(huà)和發(fā)短信。
首先在Eclipse中點(diǎn)擊菜單Windows->Open perspective->DDMS進(jìn)入DDMS視圖:

然后在DDMS視圖的Emulator Control視窗中,Incomingnumber框內填入電話(huà)號碼(隨便填),選擇Voice,然后點(diǎn)擊Call按鈕。

模擬器上即可顯示來(lái)自Incoming number的電話(huà)呼叫。

然后在Emulator Tools中選擇SMS,并填寫(xiě)短消息內容,然后點(diǎn)擊Send按鈕。

相應的模擬器上就會(huì )收到來(lái)自Incoming number發(fā)送的該短消息。

當然,如果覺(jué)得這個(gè)方法太麻煩,也可以用命令行的方式來(lái)完成上述操作,先通過(guò)命令行telnet localhost 5554,進(jìn)入AndroidConsole,然后就可以使用命令進(jìn)行一些操作,撥打電話(huà)和發(fā)送短消息是使用gsm和sms命令。gsm和sms兩個(gè)命令的參數如下:
gsm
allows you to change GSM-related settings, or to make a new inbound phonecall
available sub-commands:
list list current phone calls
call create inbound phone call
busy close waiting outbound call as busy
hold change the state of an oubtound call to 'held'
accept change the state of an outbound call to 'active'
cancel disconnect an inbound or outbound phone call
data modify data connection state
voice modify voice connection state
status display GSM status
sms
allows you to simulate an inbound SMS
available sub-commands:
send send inbound SMS text message
pdu send inbound SMS PDU
完成上述一個(gè)電話(huà)呼叫和短信的完整命令是:
gsm call 13908888888
sms send 13908888888 "this is a test sms!"
聯(lián)系客服