rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result Then
Dim p As Phone
If p.SdkVersion >= 29 Then
rp.CheckAndRequest("android.permission.ACCESS_BACKGROUND_LOCATION")
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
End If
If Result Then
Dim geo As Geofence
geo.Initialize
geo.Id = "Test2"
'-29.814433207125315, 30.90207661547709
geo.Center.Initialize2(-29.814433207125315, 30.90207661547709) 'change location!
geo.RadiusMeters = 600
geo.ExpirationMs = DateTime.TicksPerDay 'expire after one day
CallSubDelayed3(GeofenceReceiver, "AddGeofence", Me, geo)
Wait For Geofence_Added (Success As Boolean)
Log("Geofence added: " & Success)
End If
End If