Skip to content

Commit f6c01d3

Browse files
committed
merge assets, add links to official docs
1 parent 7c1d6d6 commit f6c01d3

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

assets/android.lua

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
--[[--
2-
Java Native Interface (JNI) wrapper.
2+
FFI bindings for android native APIs and Java Native Interface (JNI).
3+
4+
see https://developer.android.com/ndk/reference/struct/a-native-activity
5+
and https://developer.android.com/reference/games/game-activity/group/android-native-app-glue
36
47
@module android
58
]]
@@ -26,6 +29,8 @@ for _ = 1, 100 do end
2629
local ffi = require("ffi")
2730

2831
ffi.cdef[[
32+
// posix:
33+
int chdir(const char *path);
2934
// logging:
3035
int __android_log_print(int prio, const char *tag, const char *fmt, ...);
3136
typedef enum android_LogPriority {
@@ -2738,16 +2743,21 @@ local function run(android_app_state)
27382743
-- register the asset loader
27392744
table.insert(package.loaders, 2, android.asset_loader)
27402745

2746+
-- extract assets
27412747
local installed = android.extractAssets()
27422748
if not installed then
27432749
error("error extracting assets")
27442750
end
2745-
local launch = android.asset_loader("launcher")
2746-
if type(launch) == "function" then
2747-
return launch()
2748-
else
2749-
error("error loading launcher.lua")
2751+
2752+
-- the default current directory is root so we should first of all
2753+
-- change current directory to application's data directory
2754+
if C.chdir(android.dir) ~= 0 then
2755+
local err = "Unable to change working directory to '" .. android.dir .. "'"
2756+
android.LOGE(err)
2757+
error(err)
27502758
end
2759+
2760+
dofile(android.dir.."/llapp_main.lua")
27512761
end
27522762

27532763
run(...)

assets/launcher.lua

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)