Matching the location

The startLocationUpdates method provides the current latitude and longitude of the user continuously as per the interval we have set. We need to use the latitude and longitude information obtained and need to compare this with the latitude and longitude entered by the user for the alarm.

As and when the user enters the location of interest, we display an alert message that the User has reached the area for which the alarm has been set:

fun checkAlarmLocation(AlarmLat : Double, AlarmLong : Double, UserLat : Double,UserLong : Double) {

Toast.makeText(this,"Check Alarm Called" + AlarmLat + "," + AlarmLong + "," + UserLat + "," + UserLong,Toast.LENGTH_LONG ).show()

var LatAlarm: Double
var LongAlarm: Double
var LatUser: Double
var LongUser: Double

LatAlarm = Math.round(AlarmLat * 100.0) / 100.0;
LongAlarm = Math.round(AlarmLong * 100.0) / 100.0;

LatUser = Math.round(UserLat * 100.0) / 100.0;
LongUser = Math.round(UserLong * 100.0) / 100.0;

Toast.makeText(this,"Check Alarm Called" + LatAlarm + "," + LongAlarm + "," + LatUser + "," + LongUser,Toast.LENGTH_LONG ).show()

if (LatAlarm == LatUser && LongAlarm == LongUser) {
Toast.makeText(this, "User has reached the area for which
alarm has been set"
, Toast.LENGTH_LONG).show();
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset