1。检查意图操作
<receiver
android:name=".GeofenceBroadcastReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.location.ACTION_GEOFENCE_TRANSITION" />
</intent-filter>
</receiver>
在您的 GeofenceBroadcastReceiver 中,检查以下内容:
if (intent?.action == "com.google.android.gms.location.ACTION_GEOFENCE_TRANSITION") {
// Your geofence processing code here
}
2。检查地理围栏事件错误
val geofencingEvent = GeofencingEvent.fromIntent(intent)
if (geofencingEvent.hasError()) {
val errorMessage = GeofenceStatusCodes.getStatusCodeString(geofencingEvent.errorCode)
Log.e(TAGED, "Geofencing error: $errorMessage")
return
}