How to refresh content when opening app again

Hi,

I’ve created a simple app using Corona. When the app is loaded it retrieves data from an api and displays this data on the screen. It’s great but the next time I open the app the data is stale as it doesn’t update the data.

If I kill the app and load it again it’s fine of course. Is there a specific function or method I can use to refresh the data when the app is opened again?

Thanking you.

I’d look into https://docs.coronalabs.com/api/event/system/type.html.

Maybe try updating the data on application resume.

Thanks David. With your assistance and some googling I was able to conjure up the following code which upon a resume does an api call thus making the app data update.

function onSystemEvent( event )    if (event.type == "applicationSuspend") then         print ("\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\> suspended")     elseif (event.type == "applicationResume") then         print ("\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>   resumed")         network.request( URL, "GET", loginCallback )      end end Runtime:addEventListener( "system", onSystemEvent )

I’d look into https://docs.coronalabs.com/api/event/system/type.html.

Maybe try updating the data on application resume.

Thanks David. With your assistance and some googling I was able to conjure up the following code which upon a resume does an api call thus making the app data update.

function onSystemEvent( event )    if (event.type == "applicationSuspend") then         print ("\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\> suspended")     elseif (event.type == "applicationResume") then         print ("\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>   resumed")         network.request( URL, "GET", loginCallback )      end end Runtime:addEventListener( "system", onSystemEvent )