Demo the ability of running a NodeJS application within Android.
- Android Studio Flamingo
- NodeJS v18, npm
- Git LFS
- git lfs clone REPO
Just run the following:
./gradlew packageJsDetails:
- JS app resides in
app/demo-js - The JS app needs to be packaged into
assets/v1/demo-js.zip - gradle task
packageJsis configured to do so (and does annpm installfirst)
There's an HTML presentation about "NodeJS on Android" served by fastify running on NodeJS on port 3000 (see app/demo-js/index.js).
- Run the app on Android
- In the lifecycle navigation, open the menu on the right and ...
- Click on
prepareto install the NodeJS App to the right place - Click on
startto start the NodeJS App (in Android)
- Click on
- The webview pane (bottom nav) opens
localhost:3000and shows eventually the presentation (if the process got started)
The port is open to the world, means one can show the presentation in a browser of another device within the same network.
The app itselfs doesn't do a lot. It supports proper ProcessControl (see presentation), but no lifecycle management!
| NOAD Main | NOAD Webview |
|---|---|
- use termux to build your own NodeJS executable. Ask https://github.com/neophob for help if needed.
- the
prepareandcleanupsteps are currently blocking the main thread (which is a very bad thing). Use background jobs for such things... - there's NO lifecycle control (see presentation) implemented.
- ATTENTION: don't use TCP/IP sockets for serving under Android in real world (except you know what you're doing). Use UNIX domain sockets instead.