问题
I've been trying to send message on Android 4.0 emulator via Broadcasting and fetch that message via Broadcast receiver. I'm able to do so with two emulators, say, from 5554 to 5556. However, I can't get the sent message from 5554 to itself. Here's the way I send a message:
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(number, null, message, sentPI, deliveredPI);
the number here is emulator's port number
回答1:
You can easily demonstrate that using tellnet command : in windows os if tellnet is off then you can turn on using following steps
Start
Control Panel
Programs And Features
Turn Windows features on or off
Check Telnet Client
Hit OK
then write the command like telnet localhost 5554 here 5554 is my emulator port number
once the connection has established
write the following command filling appropriated value
sms send 5554 hi
you will see the message has arrived in your emulator .
回答2:
Yes,emulator can send messages to itself.
you can try it on your emulator.
Select messaging Application in your emulator and type your Avd no. of the emulator and send the message.
EDIT :
Reading this answer I have just tried it and Yes It's Taking the message.
I have opened my FirstAVD : 5554 and SecondAVD : 5556
then I go to Messaging :
created message to : 5554(itself) and 5556(to another) and It's showing the message to 5554 in Inbox and In avd 5556 message from FirstAVD in it's inbox.
So,Emulator sends message to itself. But while sending from one to another it will show notification and sending to itself will not show notification.
来源:https://stackoverflow.com/questions/8676866/could-one-emulator-send-a-sms-to-itself