From f2f2833b6aa70b1582623b39e9f4ba3bc59d18cc Mon Sep 17 00:00:00 2001 From: chrox Date: Wed, 29 Oct 2014 02:27:29 +0800 Subject: [PATCH] fix #1048 --- platform/android/llapp_main.lua | 24 +++++++++++++++++++++++- platform/android/luajit-launcher | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/platform/android/llapp_main.lua b/platform/android/llapp_main.lua index 7bc1e57f3..4dba5b032 100644 --- a/platform/android/llapp_main.lua +++ b/platform/android/llapp_main.lua @@ -1,6 +1,28 @@ local A = require("android") A.dl.library_path = A.dl.library_path .. ":" .. A.dir .. "/libs" +-- 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 "")) + -- create fake command-line arguments -arg = {"-d", "/sdcard"} +arg = {"-d", file or "/sdcard"} dofile(A.dir.."/reader.lua") diff --git a/platform/android/luajit-launcher b/platform/android/luajit-launcher index d7dbdb6ad..c2589c621 160000 --- a/platform/android/luajit-launcher +++ b/platform/android/luajit-launcher @@ -1 +1 @@ -Subproject commit d7dbdb6ad87917a14971ae79a0810bf6c5e29fc9 +Subproject commit c2589c621c87c0601ca9a58add297b0b7d845e77