-
Notifications
You must be signed in to change notification settings - Fork 80
The apk can be installed either using the Eclipse SDK, or directly using ADB.
If you are using Eclipse in the development cycle, then set up a Run or Debug launch configuration. This will copy the apk to the target as required.
Alternatively, use ADB directly; from the anode directory:
adb install app/bin/app.apk
The apk will install an entry on the main application launcher menu. Launching via this icon launches the main activity.
The main screen has a textfield allowing you to enter a commandline and to start a node.js instance with this runtime.
The application can be stopped either interactively from the main activity view, or can exit autonomously under programmatic control of the node.js app (with process.exit()
).
The main activity, and a background service, can each be launched via an intent.
To launch the activity:
adb shell am start -a org.meshpoint.anode.MAIN
or:
adb shell am broadcast -a org.meshpoint.anode.START
The service will be launched if a commandline argument is supplied with the intent. If you have a node.js application already on the target filesystem, eg at /data/tmp/hello.js
, then it can be launched in the service using:
adb shell am broadcast -a org.meshpoint.anode.START -e cmdline /data/tmp/hello.js
If you want to pass arguments to the instance, remember that these need to be quoted so that the entire commandline is passed as a single string:
adb shell am broadcast -a org.meshpoint.anode.START -e cmdline "/data/tmp/myapp.js argument0 argument1"
It is possible to use the intent broadcast described above to launch multiple node.js instances, and all will run in parallel.
When starting an instance, it is also possible to specify an instance identifier or name - this instance identifier can later be used to control the running of that specific instance. Use the instance
extra argument to specify the instance identifier:
adb shell am broadcast -a org.meshpoint.anode.START -e cmdline /data/tmp/myapp.js -e instance myinstance
The instance identifier can include spaces but, again, would need to be quoted:
adb shell am broadcast -a org.meshpoint.anode.START -e cmdline /data/tmp/myapp.js -e instance "myinstance with spaces"
There are two intent actions to kill running instances:
adb shell am broadcast -a org.meshpoint.anode.STOP [ -e instance instanceid ]
adb shell am broadcast -a org.meshpoint.anode.STOPALL
The STOP
action will kill the specified instance; if no instance identifier is provided and there is just one running instance, then the sole instance will be killed. If no instance identifier is specified and there are multiple instances, then STOP
does nothing.
The STOPALL
action kills all running instances.
An experimental feature is provided to avoid the need to download scripts or other assets ahead of time before launching node. An asset that is accessible via HTTP GET can be downloaded by an intent argument, and the resulting local copy then symbolically referenced in the command line.
So, concretely, suppose we want to run hello.js
, and this script is available online at http://example.com/scripts/hello.js
.
Then adding the following extra argument to the intent:
-e get:hello http://example.com/scripts/hello.js
will perform an HTTP GET to that URL and bind the local filename of the resulting file to the name hello
.
Then that name can be referenced in the cmdline argument as
%hello
So, to run this example, the complete commandline is
adb shell am broadcast -a org.meshpoint.anode.START -e get:hello http://example.com/scripts/hello.js -e cmdline %hello