You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
kind/bugSomething isn't workingplatform/android 🤖Categorizes an issue or PR as relevant to the Android platformproject/non-ui ⚙️Categorizes an issue or PR as relevant to winrt (non-ui)
RequestAccessAsync() returns GeolocationAccessStatus.Allowed, but trying to use Geolocation throws exception (no permission) - but in Manifest, permission is correct (ACCESS_FINE_LOCATION)
Expected behavior
No exception.
I tried to dig into problem, and found this info
But I never do any program for Android environment directly (only using Uno), so it would be hard for me adding appropriate code.
How to reproduce it (as minimally and precisely as possible)
Yes, it is permission problem. Permission CAN be enabled manually in system Settings, but RequestAsync() on Windows displays dialog asking for permission, and return granted/denied. On Android/Uno, RequestAsync() should be functional equivalent - ask for permission, i.e. it should call ActivityCompat.requestPermissions (from sample above). But my knowledge of Android is very, very limited, so I don't want to try to implement this code myself.
Besides, I downloaded newer Uno clone, and probably something meshed up, as it doesn't want to compile :(
And I didn't have enough time to deal with this for last days.
I started to implement this... and even found great helper function in Uno (in files src\Uno.UWP\Extensions\PermissionsHelper.cs and src\Uno.UI\Extensions\PermissionsHelper.Android.cs) ... But I don't know how to properly use CancelationToken, so I should debug it first (before PR):
public static async Task<GeolocationAccessStatus> RequestAccessAsync()
{
// below 6.0 (API 23), permission are granted
if (Android.OS.Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.M)
{
return GeolocationAccessStatus.Allowed;
}
CancellationTokenSource cts = new CancellationTokenSource();
if(await Windows.Extensions.PermissionsHelper.CheckFineLocationPermission(cts.Token))
{
return GeolocationAccessStatus.Allowed;
}
return GeolocationAccessStatus.Denied;
}
EDIT: this works only if permission is granted (using system Settings). If permission is not granted, no dialog (asking user for permission) is presented, and app seems to stop working.
@pkar70 I believe this issue is now resolved, thanks to some fixes in Uno. Could you confirm on your end that you are able to use Geolocator with the latest version of Uno on Android?
Yes, changes in permissionhelper allows to correctly implement RequestAccessAsync, and #3891 make better Geopoint.
Although #2536 have more functionality than current Uno implementation, I think this Issue can be closed.
kind/bugSomething isn't workingplatform/android 🤖Categorizes an issue or PR as relevant to the Android platformproject/non-ui ⚙️Categorizes an issue or PR as relevant to winrt (non-ui)
Activity
jeromelaban commentedon Oct 28, 2019
You may need an additional permission in the application, such as
ACCESS_COARSE_LOCATION.pkar70 commentedon Oct 28, 2019
Both (FINE and COARSE) has attribute "Protection level: dangerous" (see https://developer.android.com/reference/android/Manifest.permission.html#ACCESS_COARSE_LOCATION). And digging internet for solution I found that COARSE is 'included' in FINE, so it is unnecessary to add COARSE if someone declares FINE.
jeromelaban commentedon Oct 28, 2019
Which version of Android are you testing on?
pkar70 commentedon Oct 28, 2019
Android 8.1 Go.
jeromelaban commentedon Oct 28, 2019
In such case, it may be related to system permissions. Check that the application was given access in the devices settings.
pkar70 commentedon Oct 28, 2019
Yes, it is permission problem. Permission CAN be enabled manually in system Settings, but RequestAsync() on Windows displays dialog asking for permission, and return granted/denied. On Android/Uno, RequestAsync() should be functional equivalent - ask for permission, i.e. it should call ActivityCompat.requestPermissions (from sample above). But my knowledge of Android is very, very limited, so I don't want to try to implement this code myself.
Besides, I downloaded newer Uno clone, and probably something meshed up, as it doesn't want to compile :(
And I didn't have enough time to deal with this for last days.
pkar70 commentedon Oct 29, 2019
I started to implement this... and even found great helper function in Uno (in files src\Uno.UWP\Extensions\PermissionsHelper.cs and src\Uno.UI\Extensions\PermissionsHelper.Android.cs) ... But I don't know how to properly use CancelationToken, so I should debug it first (before PR):
EDIT: this works only if permission is granted (using system Settings). If permission is not granted, no dialog (asking user for permission) is presented, and app seems to stop working.
juliecantin commentedon Sep 3, 2020
@pkar70 I believe this issue is now resolved, thanks to some fixes in Uno. Could you confirm on your end that you are able to use Geolocator with the latest version of Uno on Android?
pkar70 commentedon Sep 3, 2020
Yes, changes in permissionhelper allows to correctly implement RequestAccessAsync, and #3891 make better Geopoint.
Although #2536 have more functionality than current Uno implementation, I think this Issue can be closed.