And the side project is done! T +1 hour 35 minutes

UPDATE: Source link now actually includes ALL the source code…

That proved to be much easier than expected… All it needed was modifying the Java server and implementing a NetConnection Thread class in an almost verbatim reproduction from the Networked Java game. I’m almost disappointed!

So without further adieu, here are the screenshots, with an explanation and source code below:

The PC runs the AndroidCommandServer jar file, and waits for a connection from the Android phone. Once a connection has been made, it waits for plain text ‘cmd’ commands and executes them when they arrive. For this demonstration, I simply sent ‘notepad’ to conjure up (almost as if by magic) a Notepad window! More usefully, this could be used for remotely locking the PC etc.

AndroidCommandServer Console

Here is a screenshot of the phone, post command issue (click for full size):

Screenshot_2013-05-02-00-42-26

As you can see, the app is very rough and ready (and actually my first time using the Eclipse plugin’s graphical element editor, as previously for soundboards and the A* pathfinder I’d always done it in the pure XML view), and I may implement the reception of text from the PC (Which would appear where ‘TextView’ currently rears it’s ugly head) but it’s not needed at the moment.

Also, for simplicity and cleanliness the phone will terminate the connection on app suspend (onPause()) by sending #disconnect which instructs the server to end the I/O streams that side.

Here is the source, also a good clean first time app for any speculative Android app writers that want a simple example (excluding the Socket stuff, but that is simple enough to be instructive too, I guess)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: