Corona SDK: network.request не работает на Android

Этот код работает на 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

Я не вижу ничего плохого в этом коде, и меня смущает тот факт, что он не работает на моем устройстве Android.

Любая помощь приветствуется

2 ответа

Решение

Обновление до последней сборки решило мою проблему

Я не вижу, что не так в вашем коде

Я думаю, что проблема в вашем устройстве Android, иногда проблема с подключением к Интернету устройства

Вы можете добавить тайм-аут по вашему запросу

local params = {}
params.timeout = 3 --in seconds

network.request( dataURL, "GET", infoFetch , params)

Так и вернется event.isError если он не загружается в течение 3 секунд

Другие вопросы по тегам