when I use Runtime:addEventListener( “location”, locationHandler ) in composer scene (example SCENE1.lua) working well and show event.latitude and event.longitute.
But when I change the scene (example SCENE2.lua) and return to previous scene (SCENE1.lua, when the addEventListener working) the addEventListener not restart and not show the gps parameters.
I would either suggest either adding the listener in main.lua if you’re going to need it in multiple scenes, or if you just need it in one scene, make sure to remove the listener when you leave that scene so you’re not stacking up listeners.
Keep in mind that it takes time to sync up with the GPS system and it’s a pretty expensive operation for your app, so starting it up early and leaving it running seems to be more practical that turning it on and off frequently.
I would either suggest either adding the listener in main.lua if you’re going to need it in multiple scenes, or if you just need it in one scene, make sure to remove the listener when you leave that scene so you’re not stacking up listeners.
Keep in mind that it takes time to sync up with the GPS system and it’s a pretty expensive operation for your app, so starting it up early and leaving it running seems to be more practical that turning it on and off frequently.