Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GPS integration into Tier 1 apps made with AGK 108 beta 18

Author
Message
Space Dream Studios
Competition Prize Winner 2014
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 1st Sep 2013 14:19 Edited at: 1st Sep 2013 18:17
Since I'm struggling arround with the integration of GPS functionality, I decided to create a step by step tutorial on the GPS subject, since I think, that there are more AppGameKit users out there with the same demand....

I didn't managed it yet to get it working, but I think I'm pretty close to the android solution. That's why I need some help now from experienced AppGameKit users

I base the tutorial on Pauls rough idea how to integrate GPS into a Tier1 android app:

You will need to find a Java example of getting a GPS location, this should be well documented. Next you will need to edit AGKHelper.java by adding your GPS code as functions you can easily use to get the location data you want, for example you could add a function GetLatitude or something, add them to the "public class AGKHelper" section. Now comes the hacking, in order to get your GPS data back into AppGameKit I recommend hijacking some functions you are not using. The video commands look ideal for this, particularly GetVideoPlaying, GetVideoWidth, etc. Find the function GetVideoValue inside AGKHelper.java and modify the switch statement to return your GPS values based on which value you want to return for each function, and clear out any video code in this function. You can then use the AppGameKit video functions to access these values. If you need to do any GPS setup, stick it in the "public static void OnStart( Activity act )" function.

So I'm going to add the GPS functionality by adding JAVA code to the AGKHelper.java section. At the end I want to extract latitude and longitude values by hijacking the getVideoHeight() and getVideoWidth() functions.

But at first, I gave the app the rights to use GPS with following line in the AndroidManifest.xml :


Then I added following JAVA code to the import segment:



After that I added:



And send the longitude and latitude values to the app by hijacking the following video functions:



But unfortunately it's not working. As soon as the app tries to recieve the values from the GETVIDEOHEIGHT or GETVIDEOWIDTH function, screen becomes blank and after a few seconds the app stops working.

Would be great if some one could check the way I went above and check for errors. Would be great if we could get it working today so we could add the iOS solution for GPS too then....

Thanks in advance!

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 1st Sep 2013 16:39
Do you have a video loaded?

'cos it looks like the hijacked function checks this first, which would stop the GPS queries.
Space Dream Studios
Competition Prize Winner 2014
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 1st Sep 2013 18:22 Edited at: 1st Sep 2013 18:29
@Marl: Thanks, you may be right. Modified it and remmed all unneeded code out and did some other small modifications.

Actually now it's running, but all values I'm getting out are "0.0"....
I guess it's not retrieving the latest values from the location listener....
Anybody any idea what I miss or how I could force the app to update data???

By the way, shouldn't be there a GPS symbol in the app showing up, if GPS is active?

Thanks a lot in advance!

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Sep 2013 22:35
Maybe I'm missing something, but why can't you use the AppGameKit commands:

GetGeolocationExists()
GetCompassExists( )
GetGyrometerExists( )
getRawGeoLatitude()
getRawGeoLongitude()

Space Dream Studios
Competition Prize Winner 2014
14
Years of Service
User Offline
Joined: 3rd Mar 2010
Location:
Posted: 2nd Sep 2013 00:30 Edited at: 2nd Sep 2013 01:11
Because the Tier 1 geolocation commands are not yet functional (please see help documentation). That's my problem, because I promised customers apps with GPS funtionality, because the command set was already in AppGameKit, but at the end, the GPS commands only work on ULTRABOOKS yet....
SO PLEASE I NEED YOUR HELP - AppGameKit MASTERS OUT THERE!!!

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 2nd Sep 2013 01:34
I don't see anything in the help documents that say they aren't functional. But a quick test with the Player on a device that has a working GPS (Nexus 7) showed that it didn't see it. But that might a configuration issue in the AndroidManifest.xml.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 2nd Sep 2013 02:12
They pretty much all say it
Quote: "
GetRawGeoLatitude

Description

If a GPS device exists, will return the latitude as a float of the current location of the device. This command is not yet functional.
"
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 2nd Sep 2013 05:09 Edited at: 2nd Sep 2013 05:11
The online documentation for that command, v10818, does not have the "This command is not yet functional." text anymore. The last version that had that text in the help page was v10817.

What version are you working with?

EDIT: Oddly, the help text included with the v10818 install does include that text.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 2nd Sep 2013 07:36
Quote: "EDIT: Oddly, the help text included with the v10818 install does include that text."


yes ...
Guido Italy
18
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 2nd Sep 2013 11:51
mmm...

repeat
print( GetGeolocationExists())
print(GetCompassExists( ))
print(GetGyrometerExists( ))
print(getRawGeoLatitude())
print(getRawGeoLongitude())
print(GetRawGeoState() )
sync()
until getpointerpressed()=1

All 0 and string null ..

On Samsung Gs3
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 2nd Sep 2013 19:13
Even with the correct line added to both the Android Player AndroidManifest.xml and an Android template file, the GPS was not recognized on my Nexus 7.

It might be that the required Java includes and such have not been done, yet. So it appears that these commands are NOT functional for Android.

And I tested in iOS on an iPad with GPS (verified with another app) and it did not work either.

So, the online documentation is not correct.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd Sep 2013 17:55 Edited at: 3rd Sep 2013 17:55
try this, add to the main AGKHelper class and separate your location class

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Sep 2013 18:52 Edited at: 3rd Sep 2013 19:04
Paul, to the import section in AGKHelper.java I added:


And I added the code indicated in AGKHelper.

EDIT: I googled the errore message and found a fix that keeps it from crashing. The code added to OnStart in AGKHelper now looks like this:


It doesn't crash, but it still says GPS not available.

This is the Tier 2 code I am testing:


By the way, welcome back. I hope you had a good holiday.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Sep 2013 21:55
Okay, I tried lots of stuff, managed to not crash, but did not manage to get the GPS to report anything.

This is the code I am now working with, and the exception is caught when requestLocationUpdates is called:


I need to work on some other things.

But I'd love to figure out how to fix this. Both for Android and iOS because I have a great app idea (which I would create for myself even if it never sells).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-09 15:38:24
Your offset time is: 2024-05-09 15:38:24