Bug 12421 - Unable to set Android.Locations.Criteria.Accuracy to High
Summary: Unable to set Android.Locations.Criteria.Accuracy to High
Status: RESOLVED UPSTREAM
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.6.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-05-28 08:27 UTC by Maxim
Modified: 2013-05-31 15:38 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Demo project (6.10 MB, application/zip)
2013-05-28 08:27 UTC, Maxim
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description Maxim 2013-05-28 08:27:43 UTC
Created attachment 4028 [details]
Demo project

Code:
var criteria = new Criteria();
criteria.Accuracy = Android.Locations.Accuracy.High;

Using Android 2.3 (API level 10) emulator. Accuracy.High was introduces in API leve 9: http://developer.android.com/intl/ru/reference/android/location/Criteria.html#ACCURACY_HIGH

Stacktrace:
[MonoDroid] UNHANDLED EXCEPTION: Java.Lang.IllegalArgumentException: Exception of type 'Java.Lang.IllegalArgumentException' was thrown.
[MonoDroid] at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00023] in /Users/builder/data/lanes/monodroid-lion-monodroid-4.6.6-branch/6d7480e9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:368
[MonoDroid] at Android.Locations.Criteria.set_Accuracy (Android.Locations.Accuracy) [0x0003e] in /Users/builder/data/lanes/monodroid-lion-monodroid-4.6.6-branch/6d7480e9/source/monodroid/src/Mono.Android/platforms/android-10/src/generated/Android.Locations.Criteria.cs:145
[MonoDroid] at Moments.Tools.LocationManagerWrapper.GetProvider () [0x00022] in /Users/mobile/Projects/msn/msn_client/MomentsAndroid/Tools/Android/Location/LocationManagerWrapper.cs:122
[MonoDroid] at Moments.Tools.LocationManagerWrapper.Start () [0x0000c] in /Users/mobile/Projects/msn/msn_client/MomentsAndroid/Tools/Android/Location/LocationManagerWrapper.cs:60
[MonoDroid] at Moments.Tools.GeoLocationManager.SubscribeOnAccurateLocationUpdated (System.Action`1<Moments.Data.Entity.Common.Location>,bool) [0x0003b] in /Users/mobile/Projects/msn/msn_client/Moments/Tools/Location/GeoLocationManager.cs:80
[MonoDroid] at Moments.Tools.GeoLocationManager.Activate () [0x000bc] in /Users/mobile/Projects/msn/msn_client/Moments/Tools/Location/GeoLocationManager.cs:125
[MonoDroid] at MomentsAndroid.MainActivity.OnCreate (Android.OS.Bundle) [0x0002a] in /Users/mobile/Projects/msn/msn_client/MomentsAndroid/MainActivity.cs:55
[MonoDroid] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-lion-monodroid-4.6.6-branch/6d7480e9/source/monodroid/src/Mono.Android/platforms/android-10/src/generated/Android.App.Activity.cs:1490
[MonoDroid] at (wrapper dynamic-method) object.1e1c022d-f352-48b2-adba-9272e2104d22 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
[MonoDroid] 
[MonoDroid]   --- End of managed exception stack trace ---
[MonoDroid] java.lang.IllegalArgumentException: accuracy=3
[MonoDroid] 	at android.location.Criteria.setAccuracy(Criteria.java:223)
[MonoDroid] 	at momentsandroid.MainActivity.n_onCreate(Native Method)
[MonoDroid] 	at momentsandroid.MainActivity.onCreate(MainActivity.java:28)
[MonoDroid] 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
[MonoDroid] 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
[MonoDroid] 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
[MonoDroid] 	at android.app.ActivityThread.access$1500(ActivityThread.java:117)
[MonoDroid] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
[MonoDroid] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[MonoDroid] 	at android.os.Looper.loop(Looper.java:123)
[MonoDroid] 	at android.app.ActivityThread.main(ActivityThread.java:3683)
[MonoDroid] 	at java.lang.reflect.Method.invokeNative(Native Method)
[MonoDroid] 	at java.lang.reflect.Method.invoke(Method.java:507)
[MonoDroid] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
[MonoDroid] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
[MonoDroid] 	at dalvik.system.NativeStart.main(Native Method)
[mono] Stacktrace:
[mono] 
[mono]   at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr) [0x00000] in /Users/builder/data/lanes/monodroid-lion-monodroid-4.6.6-branch/6d7480e9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:129
[mono]   at Java.Lang.Throwable.get_Message () [0x0003e] in /Users/builder/data/lanes/monodroid-lion-monodroid-4.6.6-branch/6d7480e9/source/monodroid/src/Mono.Android/platforms/android-10/src/generated/Java.Lang.Throwable.cs:195
[mono]   at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Comment 1 Jonathan Pryor 2013-05-28 11:41:23 UTC
This is Android; it doesn't support using ACCURACY_HIGH with Criteria.setAccuracy():

https://github.com/android/platform_frameworks_base/blob/master/location/java/android/location/Criteria.java#L221

This is apparently By Design:

http://stackoverflow.com/a/11348228/83444
Comment 2 Maxim 2013-05-31 15:38:35 UTC
My bad.