redirect to other view if no network (network.request)

Hy, i’m really newbie in corona programming.

I’m stuck in a piece of code and i can’t find solution…

i’m trying to redirect to another view if network is down and network.request fails

in SplashScreen.lua i’ve got…

local function networkListener( event )

        if ( event.isError ) then

            composer.gotoScene( “NetworkError” )

            print( “go to Network error view!” )

        else

            local phase = event.phase;

            if (phase == “ended”) then

                composer.gotoScene( “NetworkOK” )

                print( “go to Network OK view!” )

            end

        end

    end

    network.request( “http://www.google.com”, “GET”,networkListener)

end

when i open app with no network it jumps correctly in NetworkError.lua

in NetworkError.lua i’ve a button that reopens SplashScreen.lua to try again network status

sometimes works so  NetworkError.lua reopens SplashScreen.lua and (if NO NETWORK) redirect again to NetworkError.lua etc…

but mostly fails… after click on button it opens  a black screen…

i attach my code

Thanks in advance to all

Are there errors in your console log?

Rob

Thanks Rob, 

no i’ve no errors…

 but i think i’ve solved the problem…

in SplashScreen.lua

i put network.request code inside phase “did” of scene:show

now it works as i aspected

Are there errors in your console log?

Rob

Thanks Rob, 

no i’ve no errors…

 but i think i’ve solved the problem…

in SplashScreen.lua

i put network.request code inside phase “did” of scene:show

now it works as i aspected