luacoronasdkcorona-storyboard

Corona SDK: network.request not working on Android


This code works flawlessly on iOS.

When I run the same lines on my SGSII Android phone there is no progress at all. The text, laddar... is just looping infinitely.

I have added

"android.permission.INTERNET",

To my build.settings file.

Here is my code:

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

I cannot see anything wrong with this code, and I am confunded with the fact that it does not work on my android device.

Any help is appreciated


Solution

  • Updating to the latest build resolved my issue