一直不明白为什么会这样,无法上传图片,无法上传附件,点击选择上传文件按钮没有反应。最后解决方法就是下载fusionapp2.0 最新版本,网上很多提供下载的都是老版本。
然后在代码中添加
--Adam·Eva
require "import"
local uiManager=activity.getUiManager()
local webView=uiManager.getCurrentFragment().getWebView()
local WebChromeClient = luajava.bindClass "android.webkit.WebChromeClient"
webView.setWebChromeClient(luajava.override(WebChromeClient,{
onShowFileChooser=function(a, view, valueCallback, fileChooserParams)
--print(a, view, valueCallback, fileChooserParams)
uploadFile=valueCallback
local intent = fileChooserParams.createIntent()
activity.startActivityForResult(intent, 1);
return true;
end,
}))
onActivityResult=function(req,res,intent)
local Activity = luajava.bindClass "android.app.Activity"
local Uri = luajava.bindClass "android.net.Uri"
if (res == Activity.RESULT_CANCELED) then
if(uploadFile~=nil )then
uploadFile.onReceiveValue(nil);
end
end
local results
if (res == Activity.RESULT_OK)then
if(uploadFile==nil or type(uploadFile)=="number")then
return;
end
if (intent ~= nil) then
local dataString = intent.getDataString();
local clipData = intent.getClipData();
if (clipData ~= nil) then
results = Uri[clipData.getItemCount()];
for i = 0,clipData.getItemCount()-1 do
local item = clipData.getItemAt(i);
results[i] = item.getUri();
end
end
if (dataString ~= nil) then
results = Uri[1];
results[0]=Uri.parse(dataString)
end
end
end
if(results~=nil)then
uploadFile.onReceiveValue(results);
uploadFile = nil;
end
end
打包后就可以了。