1
1
--[[ --
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
3
6
4
7
@module android
5
8
]]
@@ -26,6 +29,8 @@ for _ = 1, 100 do end
26
29
local ffi = require (" ffi" )
27
30
28
31
ffi .cdef [[
32
+ // posix:
33
+ int chdir (const char * path );
29
34
// logging:
30
35
int __android_log_print (int prio , const char * tag , const char * fmt , ... );
31
36
typedef enum android_LogPriority {
@@ -2738,16 +2743,21 @@ local function run(android_app_state)
2738
2743
-- register the asset loader
2739
2744
table.insert (package.loaders , 2 , android .asset_loader )
2740
2745
2746
+ -- extract assets
2741
2747
local installed = android .extractAssets ()
2742
2748
if not installed then
2743
2749
error (" error extracting assets" )
2744
2750
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 )
2750
2758
end
2759
+
2760
+ dofile (android .dir .. " /llapp_main.lua" )
2751
2761
end
2752
2762
2753
2763
run (... )
0 commit comments