Created
September 10, 2020 15:01
-
-
Save tugcearar/25e83e7db4ea099d73d00d1c89aab3d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[BroadcastReceiver(Enabled = true)] | |
[IntentFilter(new[] { "com.huawei.hms.geofence.ACTION_PROCESS_ACTIVITY" })] | |
class GeofenceBroadcastReceiver : BroadcastReceiver | |
{ | |
public static readonly string ActionGeofence = "com.huawei.hms.geofence.ACTION_PROCESS_ACTIVITY"; | |
public override void OnReceive(Context context, Intent intent) | |
{ | |
if (intent != null) | |
{ | |
var action = intent.Action; | |
if (action == ActionGeofence) | |
{ | |
GeofenceData geofenceData = GeofenceData.GetDataFromIntent(intent); | |
if (geofenceData != null) | |
{ | |
Toast.MakeText(context, "Geofence triggered: " + geofenceData.ConvertingLocation.Latitude +"\n" + geofenceData.ConvertingLocation.Longitude + "\n" + geofenceData.Conversion.ToConversionName(), ToastLength.Long).Show(); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment