Commands
eifphone doctor # are all the tools there?
eifphone new myapp --id io.github.me.myapp --label "My App"
eifphone build myapp # signed APK in myapp/build/
eifphone run myapp # install on the device, start, show the log
eifphone log myapp --crash # crash lines only
eifphone test examples/phone_tests # on-device tests (start drive.sh first)
Options:
eifphone new <dir> --id <app.id> [--label <text>]
eifphone build [<dir>] [--abi arm64-v8a|x86_64] [--clean]
eifphone install [<dir>] [--device <serial>]
eifphone run [<dir>] [--device <serial>]
eifphone log [<dir>] [--crash] [--device <serial>]
eifphone test [<dir>] [--device <serial>]
Exit codes
| Code | Meaning |
|---|---|
| 0 | OK |
| 1 | a tool is missing, or a test failed |
| 2 | bad arguments or an invalid project |
| 3 | a version pin doesn't match |
| 4 | a build stage failed (the stage and its first error are printed) |
| 5 | a device or install problem |
A first app
class APP_MAIN
inherit PHONE_EVENT_KIND
create make
feature {NONE}
make
do
create phone.make
from until phone.lifecycle.is_destroyed loop
phone.wait_for_event -- Eiffel owns the loop; no callbacks
inspect phone.last_event.kind
when Kind_window_ready, Kind_window_resized, Kind_redraw_needed then draw
when Kind_touch_down then phone.log.info (phone.last_event.out_line)
else
end
end
end
draw
do
if phone.screen.has_window then
phone.screen.begin_frame -- Android may refuse: check in_frame
if phone.screen.in_frame then
phone.screen.fill_rect (0, 0, phone.screen.width, phone.screen.height, 0x14161C)
phone.screen.end_frame
end
end
end
phone: SIMPLE_EIF_PHONE
end
What the phone object gives you
| Call | Gives you |
|---|---|
phone.wait_for_event, phone.poll_event (ms) | The next event, in phone.last_event |
phone.lifecycle | Started, resumed, has a window, has focus, destroyed |
phone.touches | Every finger now down, by pointer id |
phone.screen | Frames: begin_frame, fill_rect, present_argb, end_frame |
phone.metrics | Size, density, system-bar insets, dp |
phone.storage | The app's private folder, and its external folder if there is one |
phone.assets | Files packed into the APK |
phone.log | Lines to the Android log |
phone.set_back_policy, set_keep_screen_on, finish | Back key, screen timeout, leaving the app |
Every feature and contract is in the API Reference.