This is my build.setting file :
-- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight settings = { orientation = { default = "portrait", supported = { "portrait", } }, android = { versionCode = "1", usesPermissions = { "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", }, }, }
and my view 2 where is the network.listener.
----------------------------------------------------------------------------------------- -- -- view2.lua -- ----------------------------------------------------------------------------------------- ligne = {} local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local function networkListener ( event ) local path = system.pathForFile( event.response.filename, event.response.baseDirectory ) local file = io.open( path, "r" ) nbr\_ligne=1 for line in file:lines() do ligne[nbr\_ligne] = tostring(line) nbr\_ligne=nbr\_ligne+1 end io.close( file ) file = nil nbr\_pronos = (nbr\_ligne-1)/4 for i = 1,nbr\_pronos do ligne[i] = display.newText( ligne[i], 10, 10\*i, native.systemFont, 24) ligne[i]:setTextColor(0,0,0) end end ----------------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION -- -- NOTE: Code outside of listener functions (below) will only be executed once, -- unless storyboard.removeScene() is called. -- ----------------------------------------------------------------------------------------- -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view local physics = require "physics" physics.start() -- create a white background to fill screen --local bg = display.newImage( "pronostics4.png" ) --local bgp = display.newImage( "Pronostics2.png" ) local grass = display.newImage( "grass.png" ) grass.y = 480 physics.addBody( grass, "static", { friction =0.1 } ) --ballon local crate = display.newImage( "ballonbasket.png" ) crate.x, crate.y = 130, 50 crate.rotation = 50 crate.width = 60 crate.height = 60 physics.addBody( crate, { bounce=1 } ) physics.addBody( grass, "static", { friction =0.1 } ) --ballon local crate = display.newImage( "ballonfoot.png" ) crate.x, crate.y = 190, 50 crate.rotation = 70 crate.width = 60 crate.height = 60 physics.addBody( crate, { bounce=1 } ) physics.addBody( grass, "static", { friction =0.1 } ) --ballon local crate = display.newImage( "balletennis.png" ) crate.x, crate.y = 170, 50 crate.rotation = 50 crate.width = 30 crate.height = 30 physics.addBody( crate, { bounce=1 } ) network.download( "http://devkevin.olympe.in/pronostics.txt", "GET", networkListener,"pronostics.txt",system.TemporaryDirectory ) if event.phase == "ended" then and end -- create some text --local title = display.newText( "Pronostics", 0, 0, native.systemFont, 32 ) -- title:setTextColor( 255 ) -- white -- title:setReferencePoint( display.CenterReferencePoint ) -- title.x = 90 -- title.y = 50 -- local summary = display.newText( "Loaded by the first tab 'onPress' listener\n— specified in the 'tabButtons' table.", 0, 0, 300, 300, native.systemFont, 14 ) -- summary:setTextColor( 0 ) -- black -- summary:setReferencePoint( display.CenterReferencePoint ) -- summary.x = display.contentWidth \* 0.5 + 10 -- summary.y = title.y + 215 -- all objects must be added to group (e.g. self.view) -- group:insert( bg ) -- group:insert( bgp ) group:insert( grass ) -- group:insert( summary ) end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view -- do nothing end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view -- INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.) end -- If scene's view is removed, scene:destroyScene() will be called just prior to: function scene:destroyScene( event ) local group = self.view -- INSERT code here (e.g. remove listeners, remove widgets, save state variables, etc.) end ----------------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION ----------------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched whenever before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) ----------------------------------------------------------------------------------------- return scene