EDIT: This solution is no longer necessary (copy-paste didn't work for me back in 2013, but it works now.)
I had a similar need awhile ago. My solution was to write a quick app that listens on a UDP port and dumps anything coming in on that port to a SMS (text) message.
Then from the host machine I sent it with netcat from the shell.
UDP listener app code:
package com.example.messagemyself;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;
import android.app.Service;
import android.content.ContentValues;
import android.net.Uri;
import android.util.Log;
public class GetUDPData extends Thread {
private static final String TAG = "GetUDPData";
private DatagramSocket datagramSocket;
private DatagramPacket packet;
boolean running = true;
Service srv;
public GetUDPData(Service s) {
srv = s;
}
public void done() {
datagramSocket.close();
running = false;
}
@Override
public void run() {
try {
datagramSocket = new DatagramSocket(4444);
datagramSocket.setSoTimeout(0);
byte[] buffer = new byte[1024];
packet = new DatagramPacket(buffer, buffer.length);
} catch (SocketException e) {
e.printStackTrace();
}
while(running) {
try {
Log.d(TAG,"Receiving");
datagramSocket.receive(packet);
String message = new String(packet.getData(),0,packet.getLength());
Log.d(TAG,"Received "+message);
ContentValues values = new ContentValues();
values.put("address", "12345");
values.put("body", message);
// Post to SMS inbox
srv.getContentResolver().insert(Uri.parse("content://sms/inbox"), values);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Run this thread in an app (you could use the default hello-world one for example);
Then to send your text message, run netcat with the -u option for UDP:
echo "my message" | nc -u 192.168.56.101 4444
Don't forget to use your genymotion ip address here.
I also went one step further and created a python script that grabs data from the system clipboard and dumps it out the UDP port. This could be useful too, especially if you want to send non-ascii text or something (in my case I needed to send Japanese characters and setting up the windows shell to display the characters turned out to be a feat that I don't wish upon the faint of heart.)
Anyway, here's the script. Dump it into a .py file and then double-click it to send the contents of the clipboard to the UDP socket.
from Tkinter import Tk
r = Tk()
datatosend = r.selection_get(selection = "CLIPBOARD")
r.destroy()
import time
import socket
UDP_IP = "192.168.56.101"
UDP_PORT = 4444
print "sending SMS: %s"%datatosend
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sock.sendto(datatosend, (UDP_IP, UDP_PORT))
time.sleep(3)
# The sleep is not necessary, but I like it since you can see the
# message for a bit before the shell exits.