xamarin 跨平台地理围栏
Geofence for xamarin crossplatform
我目前为 DevEddy 的 xamarin 实现了一个地理围栏插件(我使用它是因为它有一个示例项目并且最近更新了)。它工作正常。
问题:
当我将 android 位置 mode/proviedr 设置设置为 "Use GPS only (Device Only)" 而不是 gps、wifi、移动网络和 运行 我的应用程序崩溃时,并发送以下错误:
Android.Gms.Common.Apis.ApiException: 1000:
整个输出:
Unhandled Exception:
Android.Gms.Common.Apis.ApiException: 1000:
11-12 11:01:08.337 D/Mono ( 5466): DllImport attempting to load: '/system/lib64/liblog.so'.
11-12 11:01:08.338 D/Mono ( 5466): DllImport loaded library '/system/lib64/liblog.so'.
11-12 11:01:08.338 D/Mono ( 5466): DllImport searching in: '/system/lib64/liblog.so' ('/system/lib64/liblog.so').
11-12 11:01:08.338 D/Mono ( 5466): Searching for '__android_log_print'.
11-12 11:01:08.338 D/Mono ( 5466): Probing '__android_log_print'.
11-12 11:01:08.338 D/Mono ( 5466): Found as '__android_log_print'.
11-12 11:01:08.343 I/MonoDroid( 5466): UNHANDLED EXCEPTION:An unhandled exception occured.
11-12 11:01:08.357 D/Mono ( 5466): DllImport searching in: '__Internal' ('(null)').
11-12 11:01:08.357 D/Mono ( 5466): Searching for 'java_interop_jnienv_is_assignable_from'.
11-12 11:01:08.357 D/Mono ( 5466): Probing 'java_interop_jnienv_is_assignable_from'.
11-12 11:01:08.358 D/Mono ( 5466): Found as 'java_interop_jnienv_is_assignable_from'.
11-12 11:01:08.366 I/MonoDroid( 5466): Android.Gms.Common.Apis.ApiException: 1000:
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at Plugin.Geofencing.GeofencingImplementation+<StartMonitoring>d__10.MoveNext () [0x000f0] in <aa9ff56f4a7a4b72b03925c3bf41ed1d>:0
11-12 11:01:08.366 I/MonoDroid( 5466): --- End of stack trace from previous location where exception was thrown ---
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <a10f61e70eeb434e952fef884856c199>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <a10f61e70eeb434e952fef884856c199>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <a10f61e70eeb434e952fef884856c199>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at (wrapper dynamic-method) System.Object.38(intptr,intptr)
11-12 11:01:08.366 I/MonoDroid( 5466): --- End of managed Android.Gms.Common.Apis.ApiException stack trace ---
11-12 11:01:08.366 I/MonoDroid( 5466): com.google.android.gms.common.api.ApiException: 1000:
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.internal.zzb.zzx(Unknown Source:14)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.internal.zzbj.zzy(Unknown Source:0)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.internal.zzbk.zzq(Unknown Source:32)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source:46)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source:40)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.location.LocationServices$zza.setResult(Unknown Source:2)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.internal.zzbzv.zza(Unknown Source:22)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.internal.zzbzj.onTransact(Unknown Source:22)
11-12 11:01:08.366 I/MonoDroid( 5466): at android.os.Binder.execTransact(Binder.java:675)
11-12 11:01:08.366 I/MonoDroid( 5466):
11-12 11:01:08.374 D/Mono ( 5466): DllImport searching in: '__Internal' ('(null)').
11-12 11:01:08.374 D/Mono ( 5466): Searching for 'java_interop_jnienv_throw'.
11-12 11:01:08.374 D/Mono ( 5466): Probing 'java_interop_jnienv_throw'.
11-12 11:01:08.374 D/Mono ( 5466): Found as 'java_interop_jnienv_throw'.
11-12 11:01:09.489 E/mono ( 5466):
11-12 11:01:09.489 E/mono ( 5466): Unhandled Exception:
11-12 11:01:09.489 E/mono ( 5466): Android.Gms.Common.Apis.ApiException: 1000:
11-12 11:01:09.489 E/mono ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.489 E/mono ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.489 E/mono ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.489 E/mono ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.489 E/mono ( 5466): at Plugin.Geofencing.GeofencingImplementation+<StartMonitoring>d__10.MoveNext () [0x000f0] in <aa9ff56f4a7a4b72b03925c3bf41ed1d>:0
11-12 11:01:09.489 E/mono ( 5466): --- End of stack trace from previous location where exception was thrown ---
11-12 11:01:09.489 E/mono ( 5466): at (wrapper dynamic-method) System.Object.38(intptr,intptr)
11-12 11:01:09.489 E/mono ( 5466): --- End of managed Android.Gms.Common.Apis.ApiException stack trace ---
11-12 11:01:09.489 E/mono ( 5466): com.google.android.gms.common.api.ApiException: 1000:
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.internal.zzb.zzx(Unknown Source:14)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.internal.zzbj.zzy(Unknown Source:0)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.internal.zzbk.zzq(Unknown Source:32)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source:46)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source:40)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.location.LocationServices$zza.setResult(Unknown Source:2)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.internal.zzbzv.zza(Unknown Source:22)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.internal.zzbzj.onTransact(Unknown Source:22)
11-12 11:01:09.489 E/mono ( 5466): at android.os.Binder.execTransact(Binder.java:675)
11-12 11:01:09.489 E/mono ( 5466):
11-12 11:01:09.528 D/Mono ( 5466): GC_BRIDGE waiting for bridge processing to finish
11-12 11:01:09.548 I/zygote64( 5466): Explicit concurrent copying GC freed 4872(791KB) AllocSpace objects, 9(180KB) LOS objects, 91% free, 1197KB/13MB, paused 335us total 21.486ms
11-12 11:01:09.550 D/Mono ( 5466): GC_TAR_BRIDGE bridges 103 objects 4378 opaque 2115 colors 103 colors-bridged 103 colors-visible 103 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.14ms tarjan 4.97ms scc-setup 0.10ms gather-xref 0.01ms xref-setup 0.03ms cleanup 0.31ms
11-12 11:01:09.551 D/Mono ( 5466): GC_BRIDGE: Complete, was running for 24.37ms
11-12 11:01:09.551 D/Mono ( 5466): GC_MINOR: (Nursery full) time 31.28ms, stw 33.35ms promoted 963K major size: 3216K in use: 2457K los size: 2048K in use: 916K
11-12 11:01:09.551 E/mono-rt ( 5466): [ERROR] FATAL UNHANDLED EXCEPTION: Android.Gms.Common.Apis.ApiException: 1000:
11-12 11:01:09.551 E/mono-rt ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.551 E/mono-rt ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.551 E/mono-rt ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.551 E/mono-rt ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.551 E/mono-rt ( 5466): at Plugin.Geofencing.GeofencingImplementation+<StartMonitoring>d__10.MoveNext () [0x000f0] in <aa9ff56f4a7a4b72b03925c3bf41ed1d>:0
11-12 11:01:09.551 E/mono-rt ( 5466): --- End of stack trace from previous location where exception was thrown ---
11-12 11:01:09.551 E/mono-rt ( 5466): at (wrapper dynamic-method) System.Object.38(intptr,intptr)
11-12 11:01:09.551 E/mono-rt ( 5466): --- End of managed Android.Gms.Common.Apis.ApiException stack trace ---
11-12 11:01:09.551 E/mono-rt ( 5466): com.google.android.gms.common.api.ApiException: 1000:
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.internal.zzb.zzx(Unknown Source:14)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.internal.zzbj.zzy(Unknown Source:0)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.internal.zzbk.zzq(Unknown Source:32)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source:46)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source:40)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.location.LocationServices$zza.setResult(Unknown Source:2)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.internal.zzbzv.zza(Unknown Source:22)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.internal.zzbzj.onTransact(Unknown Source:22)
11-12 11:01:09.551 E/mono-rt ( 5466): at android.os.Binder.execTransact(Binder.java:675)
11-12 11:01:09.551 E/mono-rt ( 5466):
我不确定问题是关于 permission/config 还是插件,如果是,我该如何解决。
目前我正在使用以下代码检查权限以及是否启用了 gps:
var permissionsGranted = await CrossGeofencing.Current.RequestPermission();
if (!permissionsGranted.ToString().Equals("Granted"))
//do something
return;
if (!IsLocationAvailable())
{
//do something
return;
}
IsLocationAvailable 函数:
public bool IsLocationAvailable()
{
if (!CrossGeolocator.IsSupported)
return false;
if (!CrossGeolocator.Current.IsGeolocationEnabled)
return false;
if (!CrossGeolocator.Current.IsGeolocationAvailable)
return false;
if (!CrossGeofencing.IsSupported)
return false;
return true;
}
如有任何建议,我们将不胜感激!
谢谢
1000
= GEOFENCE_NOT_AVAILABLE
您需要最新的 GPS_PROVIDER 和 NETWORK_PROVIDER 才能使 GeoFencing 正常工作,因为它必须检测您在不同位置的位置,包括在内部或者如果您处于“GPS 阴影”时。
public static final int GEOFENCE_NOT_AVAILABLE
Geofence service is not available now. Typically this is because the user turned off location access in settings > location access.
Constant Value: 1000
关于这个的 Whosebug 有很多questions/answers,你可以搜索
如何检查这些服务是否可用的示例:
我目前为 DevEddy 的 xamarin 实现了一个地理围栏插件(我使用它是因为它有一个示例项目并且最近更新了)。它工作正常。
问题: 当我将 android 位置 mode/proviedr 设置设置为 "Use GPS only (Device Only)" 而不是 gps、wifi、移动网络和 运行 我的应用程序崩溃时,并发送以下错误:
Android.Gms.Common.Apis.ApiException: 1000:
整个输出:
Unhandled Exception:
Android.Gms.Common.Apis.ApiException: 1000:
11-12 11:01:08.337 D/Mono ( 5466): DllImport attempting to load: '/system/lib64/liblog.so'.
11-12 11:01:08.338 D/Mono ( 5466): DllImport loaded library '/system/lib64/liblog.so'.
11-12 11:01:08.338 D/Mono ( 5466): DllImport searching in: '/system/lib64/liblog.so' ('/system/lib64/liblog.so').
11-12 11:01:08.338 D/Mono ( 5466): Searching for '__android_log_print'.
11-12 11:01:08.338 D/Mono ( 5466): Probing '__android_log_print'.
11-12 11:01:08.338 D/Mono ( 5466): Found as '__android_log_print'.
11-12 11:01:08.343 I/MonoDroid( 5466): UNHANDLED EXCEPTION:An unhandled exception occured.
11-12 11:01:08.357 D/Mono ( 5466): DllImport searching in: '__Internal' ('(null)').
11-12 11:01:08.357 D/Mono ( 5466): Searching for 'java_interop_jnienv_is_assignable_from'.
11-12 11:01:08.357 D/Mono ( 5466): Probing 'java_interop_jnienv_is_assignable_from'.
11-12 11:01:08.358 D/Mono ( 5466): Found as 'java_interop_jnienv_is_assignable_from'.
11-12 11:01:08.366 I/MonoDroid( 5466): Android.Gms.Common.Apis.ApiException: 1000:
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at Plugin.Geofencing.GeofencingImplementation+<StartMonitoring>d__10.MoveNext () [0x000f0] in <aa9ff56f4a7a4b72b03925c3bf41ed1d>:0
11-12 11:01:08.366 I/MonoDroid( 5466): --- End of stack trace from previous location where exception was thrown ---
11-12 11:01:08.366 I/MonoDroid( 5466): at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <a10f61e70eeb434e952fef884856c199>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <a10f61e70eeb434e952fef884856c199>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <a10f61e70eeb434e952fef884856c199>:0
11-12 11:01:08.366 I/MonoDroid( 5466): at (wrapper dynamic-method) System.Object.38(intptr,intptr)
11-12 11:01:08.366 I/MonoDroid( 5466): --- End of managed Android.Gms.Common.Apis.ApiException stack trace ---
11-12 11:01:08.366 I/MonoDroid( 5466): com.google.android.gms.common.api.ApiException: 1000:
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.internal.zzb.zzx(Unknown Source:14)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.internal.zzbj.zzy(Unknown Source:0)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.internal.zzbk.zzq(Unknown Source:32)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source:46)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source:40)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.location.LocationServices$zza.setResult(Unknown Source:2)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.internal.zzbzv.zza(Unknown Source:22)
11-12 11:01:08.366 I/MonoDroid( 5466): at com.google.android.gms.internal.zzbzj.onTransact(Unknown Source:22)
11-12 11:01:08.366 I/MonoDroid( 5466): at android.os.Binder.execTransact(Binder.java:675)
11-12 11:01:08.366 I/MonoDroid( 5466):
11-12 11:01:08.374 D/Mono ( 5466): DllImport searching in: '__Internal' ('(null)').
11-12 11:01:08.374 D/Mono ( 5466): Searching for 'java_interop_jnienv_throw'.
11-12 11:01:08.374 D/Mono ( 5466): Probing 'java_interop_jnienv_throw'.
11-12 11:01:08.374 D/Mono ( 5466): Found as 'java_interop_jnienv_throw'.
11-12 11:01:09.489 E/mono ( 5466):
11-12 11:01:09.489 E/mono ( 5466): Unhandled Exception:
11-12 11:01:09.489 E/mono ( 5466): Android.Gms.Common.Apis.ApiException: 1000:
11-12 11:01:09.489 E/mono ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.489 E/mono ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.489 E/mono ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.489 E/mono ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.489 E/mono ( 5466): at Plugin.Geofencing.GeofencingImplementation+<StartMonitoring>d__10.MoveNext () [0x000f0] in <aa9ff56f4a7a4b72b03925c3bf41ed1d>:0
11-12 11:01:09.489 E/mono ( 5466): --- End of stack trace from previous location where exception was thrown ---
11-12 11:01:09.489 E/mono ( 5466): at (wrapper dynamic-method) System.Object.38(intptr,intptr)
11-12 11:01:09.489 E/mono ( 5466): --- End of managed Android.Gms.Common.Apis.ApiException stack trace ---
11-12 11:01:09.489 E/mono ( 5466): com.google.android.gms.common.api.ApiException: 1000:
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.internal.zzb.zzx(Unknown Source:14)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.internal.zzbj.zzy(Unknown Source:0)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.internal.zzbk.zzq(Unknown Source:32)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source:46)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source:40)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.location.LocationServices$zza.setResult(Unknown Source:2)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.internal.zzbzv.zza(Unknown Source:22)
11-12 11:01:09.489 E/mono ( 5466): at com.google.android.gms.internal.zzbzj.onTransact(Unknown Source:22)
11-12 11:01:09.489 E/mono ( 5466): at android.os.Binder.execTransact(Binder.java:675)
11-12 11:01:09.489 E/mono ( 5466):
11-12 11:01:09.528 D/Mono ( 5466): GC_BRIDGE waiting for bridge processing to finish
11-12 11:01:09.548 I/zygote64( 5466): Explicit concurrent copying GC freed 4872(791KB) AllocSpace objects, 9(180KB) LOS objects, 91% free, 1197KB/13MB, paused 335us total 21.486ms
11-12 11:01:09.550 D/Mono ( 5466): GC_TAR_BRIDGE bridges 103 objects 4378 opaque 2115 colors 103 colors-bridged 103 colors-visible 103 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.14ms tarjan 4.97ms scc-setup 0.10ms gather-xref 0.01ms xref-setup 0.03ms cleanup 0.31ms
11-12 11:01:09.551 D/Mono ( 5466): GC_BRIDGE: Complete, was running for 24.37ms
11-12 11:01:09.551 D/Mono ( 5466): GC_MINOR: (Nursery full) time 31.28ms, stw 33.35ms promoted 963K major size: 3216K in use: 2457K los size: 2048K in use: 916K
11-12 11:01:09.551 E/mono-rt ( 5466): [ERROR] FATAL UNHANDLED EXCEPTION: Android.Gms.Common.Apis.ApiException: 1000:
11-12 11:01:09.551 E/mono-rt ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.551 E/mono-rt ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.551 E/mono-rt ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.551 E/mono-rt ( 5466): at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0
11-12 11:01:09.551 E/mono-rt ( 5466): at Plugin.Geofencing.GeofencingImplementation+<StartMonitoring>d__10.MoveNext () [0x000f0] in <aa9ff56f4a7a4b72b03925c3bf41ed1d>:0
11-12 11:01:09.551 E/mono-rt ( 5466): --- End of stack trace from previous location where exception was thrown ---
11-12 11:01:09.551 E/mono-rt ( 5466): at (wrapper dynamic-method) System.Object.38(intptr,intptr)
11-12 11:01:09.551 E/mono-rt ( 5466): --- End of managed Android.Gms.Common.Apis.ApiException stack trace ---
11-12 11:01:09.551 E/mono-rt ( 5466): com.google.android.gms.common.api.ApiException: 1000:
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.internal.zzb.zzx(Unknown Source:14)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.internal.zzbj.zzy(Unknown Source:0)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.internal.zzbk.zzq(Unknown Source:32)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source:46)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source:40)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.location.LocationServices$zza.setResult(Unknown Source:2)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.internal.zzbzv.zza(Unknown Source:22)
11-12 11:01:09.551 E/mono-rt ( 5466): at com.google.android.gms.internal.zzbzj.onTransact(Unknown Source:22)
11-12 11:01:09.551 E/mono-rt ( 5466): at android.os.Binder.execTransact(Binder.java:675)
11-12 11:01:09.551 E/mono-rt ( 5466):
我不确定问题是关于 permission/config 还是插件,如果是,我该如何解决。
目前我正在使用以下代码检查权限以及是否启用了 gps:
var permissionsGranted = await CrossGeofencing.Current.RequestPermission();
if (!permissionsGranted.ToString().Equals("Granted"))
//do something
return;
if (!IsLocationAvailable())
{
//do something
return;
}
IsLocationAvailable 函数:
public bool IsLocationAvailable()
{
if (!CrossGeolocator.IsSupported)
return false;
if (!CrossGeolocator.Current.IsGeolocationEnabled)
return false;
if (!CrossGeolocator.Current.IsGeolocationAvailable)
return false;
if (!CrossGeofencing.IsSupported)
return false;
return true;
}
如有任何建议,我们将不胜感激! 谢谢
1000
= GEOFENCE_NOT_AVAILABLE
您需要最新的 GPS_PROVIDER 和 NETWORK_PROVIDER 才能使 GeoFencing 正常工作,因为它必须检测您在不同位置的位置,包括在内部或者如果您处于“GPS 阴影”时。
public static final int GEOFENCE_NOT_AVAILABLE
Geofence service is not available now. Typically this is because the user turned off location access in settings > location access.
Constant Value: 1000
关于这个的 Whosebug 有很多questions/answers,你可以搜索
如何检查这些服务是否可用的示例: