I'm currently writing an app to get the users location. I have done this before and it worked great but something seems to have changed.
Calling
StartGPSTracking() at the start of my Android app seems to cause it to stop responding to screen taps and other input in the main loop. It reaches a point where the OS asks to terminate the app due to it not responding. The odd thing is that the FPS counter in the loop continues to print to the screen so something is causing an issue in the background.
IMPORTANT: Everything works perfectly when broadcasting to the AppGameKit Player (version 2023.01.25 from Google Play). This problem only occurs when I build an APK and install it on a real device using AppGameKit Studio (v2024.08.15). I've tested this with an Android 14 phone and an old Android 7 phone with the same results.
Here is an example app to demonstrate the problem.
SetErrorMode(2)
SetWindowTitle( "LocationTest" )
SetWindowSize( 720, 1280, 0 )
SetWindowAllowResize( 1 )
// set display properties
SetVirtualResolution( 720, 1280 )
SetOrientationAllowed( 1, 1, 0, 0 )
SetSyncRate( 30, 0 )
UseNewDefaultFonts( 1 )
Global Latitude as float
Global Longitude as float
// Trigger permission request for GPS access.
if ( CheckPermission( "Location" ) <= 0 )
RequestPermission( "Location" )
while( CheckPermission( "Location" ) = 1 )
Sync()
endwhile
endif
// Start the GPS system so we can read location info. This seems to be the problem.
StartGPSTracking()
Latitude = GetRawGPSLatitude()
Longitude = GetRawGPSLongitude()
AddVirtualButton(1, 200,200, 200)
do
if (GetVirtualButtonState(1) = 1) then Print("BUTTON DOWN!")
if (GetVirtualButtonReleased(1))
Latitude = GetRawGPSLatitude()
Longitude = GetRawGPSLongitude()
endif
Print("Latitude: " + Str(Latitude,4))
Print("Longitude: " + Str(Longitude,4))
Print( ScreenFPS() )
Sync()
loop
If you broadcast this to the AppGameKit Player app you can press the virtual button and see it instantly respond, printing to the screen and updating the coordinates.
If you build an APK file and install it to a device (ensuring you tick "Precise Location" and "Coarse Location" to be sure) you will find that it doesn't respond to pressing the virtual button and will eventually popup an "isn't responding" message.
Am I missing something or forgetting to tick something which is automatically turned on for the AppGameKit Player app?