aleross / ShellCommand

Android classes for adding an interactive shell interface to any Android app, primarily for quicker debugging.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shell Command

A wonderfully easy to use tool for adding command-line interactivity to your app.

Most physical android devices use 10.0.2.2 as localhost.

App Usage

Arguments are broken up into an array after taking into account single and double quotes. Integers and doubles are appropriately cast into their respective types. It's up to you to validate/check this array for arguments your app cares about.

Use the command "exit" to leave the interactive shell. The socket will remain up and available for the next connection.

Limited formatting is supported in ShellCommandFormatters, sample calls are shown in MyActivity.

An executor service runs every 10 minutes checking whether the socket is still up, it will restart it if it is not.

Command-Line Usage

Use netcat (available on the Android emulator) or telnet to connect to the server socket. For example, to connect on your emulator you would call

nc 127.0.0.1 8000 

The sample activity should be ready to go, just load it into your emulator and enter your emulator's shell via ./adb shell. If you have more than device use the -s flag:

./adb -s [deviceName] shell. 

You can find your emulator's device name by using

./adb devices.

If ShellCommand stops and you need to restart it remotely, you can broadcast an Intent with an optional port as an extra. Example:

am broadcast -a com.aleross.shellcommand.START -e PORT 8002    

Requirements

Note that Activity's implementing ShellCommand must include the uses INTERNET statement in their AndroidManifest.xml.

<uses-permission android:name="android.permission.INTERNET"/>

About

Android classes for adding an interactive shell interface to any Android app, primarily for quicker debugging.


Languages

Language:Java 100.0%