2
0
mirror of https://github.com/koreader/koreader synced 2024-11-18 03:25:46 +00:00
koreader/platform/android/llapp_main.lua

32 lines
894 B
Lua
Raw Normal View History

local A = require("android")
A.dl.library_path = A.dl.library_path .. ":" .. A.dir .. "/libs"
2014-10-28 18:27:29 +00:00
-- check uri of the intent that starts this application
local file = A.jni:context(A.app.activity.vm, function(JNI)
local uri = JNI:callObjectMethod(
JNI:callObjectMethod(
A.app.activity.clazz,
"getIntent",
"()Landroid/content/Intent;"
),
"getData",
"()Landroid/net/Uri;"
)
if uri ~= nil then
local path = JNI:callObjectMethod(
uri,
"getPath",
"()Ljava/lang/String;"
)
return JNI:to_string(path)
end
end)
A.LOGI("intent file path " .. (file or ""))
-- run koreader patch before koreader startup
pcall(function() dofile("/sdcard/koreader/patch.lua") end)
-- create fake command-line arguments
2014-10-28 18:27:29 +00:00
arg = {"-d", file or "/sdcard"}
dofile(A.dir.."/reader.lua")