【发布时间】:2013-07-03 17:28:40
【问题描述】:
此代码在 iOS 上完美运行。
当我在我的 SGSII Android 手机上运行相同的行时,根本没有任何进展。文本laddar... 只是无限循环。
我已经添加了
"android.permission.INTERNET",
到我的 build.settings 文件。
这是我的代码:
local function fetchDataFromURL()
local loadingText = display.newText("no text", 0,0,"Sintony", 40)
loadingText.text = "Laddar stipendier..."
loadingText:setReferencePoint(display.CenterLeftReferencePoint)
loadingText.x = mainBox.x - loadingText.width/2
loadingText.y = mainBox.y
local function updateLoadingText()
if (loadingText.text == "Laddar stipendier") then loadingText.text = "Laddar stipendier."
elseif (loadingText.text == "Laddar stipendier.") then loadingText.text = "Laddar stipendier.."
elseif (loadingText.text == "Laddar stipendier..") then loadingText.text = "Laddar stipendier..."
elseif (loadingText.text == "Laddar stipendier...") then loadingText.text = "Laddar stipendier"
end
loadingText:setReferencePoint(display.CenterLeftReferencePoint)
loadingText.x = 134
end
local loadingTimer = timer.performWithDelay(500, updateLoadingText, 0)
local function compare(a,b)
return a.title < b.title
end
local function infoFetch(event)
-- perform basic error handling
if ( event.isError ) then
print( "Network error!")
else
local data = json.decode(event.response)
scholarshipTable = data.scholarships
for key, value in pairs(scholarshipTable) do
table.insert(namesOfScholarship,{title = value.title, id = value.id})
end
table.sort(namesOfScholarship, compare)
timer.cancel(loadingTimer)
loadingText:removeSelf()
loadingText = nil
createTableView()
return true
end
end
network.request( dataURL, "GET", infoFetch )
end
我看不出这段代码有什么问题,而且我对它在我的安卓设备上不起作用这一事实感到困惑。
感谢任何帮助
【问题讨论】:
-
如果 HTTP 请求返回状态为 201 时会触发一个错误,它似乎永远不会返回,但不久前已修复。使用的是什么版本的 Corona?您在哪个版本的 Android 上运行?
-
有趣。我相信是 .1137 或 .1156
-
这个bug出现在哪个版本?
标签: lua coronasdk corona-storyboard