Skip to main content
Inspiring
December 25, 2017
Answered

Geolocation permission on Android with AIR 28

  • December 25, 2017
  • 2 replies
  • 1151 views

Hi,

I just saw that, with AIR 28, we need to ask permission to the user within the app for Geolocation.

I read the example in the AIR 28 Release Note but it's only about Camera.

Does someone could help me and tell me all the steps to ask the user to allow the geolocation please ?

Do I only have to put it in AS3 code ?

If so, is it something like this ? :

var _userGeo2 = new Geolocation()

if (Geolocation.isSupported){         

                if (Geolocation.permissionStatus != PermissionStatus.GRANTED){

                    _userGeo2.addEventListener(PermissionEvent.PERMISSION_STATUS, function(e:PermissionEvent):void {

                        if (e.status == PermissionStatus.GRANTED)     {

                            // WHAT SHOUD I PUT HERE ????

                        }

                        else {

                            // permission denied

                        }

                    });

Do I have to change something in the xml file as well of can I just let this line ?

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

This topic has been closed for replies.
Correct answer kglad

in my experience, it doesn't work to request permission after a user has denied it on app start-up, but it wouldn't hurt to try.

check for permission, if granted proceed; if not, don't try to utilize geolocation.

2 replies

Inspiring
December 25, 2017

Hmm I think I should also put

try {

                        _userGeo2.requestPermission();

                    }

No?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 25, 2017

in my experience, it doesn't work to request permission after a user has denied it on app start-up, but it wouldn't hurt to try.

check for permission, if granted proceed; if not, don't try to utilize geolocation.

kglad
Community Expert
Community Expert
December 25, 2017

yes, that xml needs to be in your app descriptor.

Inspiring
December 25, 2017

OK, but what should I put on the line

"WHAT SHOUD I PUT HERE ???"