Am trying to make an app which detects if user is near to a predefined target location and shows a toast message..
now i dont want to make the user enable the GPS ..can the auto enable to GPS? is there any other way to get location in B4a?
How exactly do you want to define the users' location? Triangulating off masts isn't as nearly as accurate as GPS, but is generally much faster and you don't have to get GPS turned on.
its working and i allways get a notification pointing to the nearest destination.
is there a better way to get distance between two points? so far, i am not using the GPS of the device. lat lon coordinates are being fetched from the locationmanager .
This is the generic equation to measure the distance between any 2 points..
DistanceBetween = Sqr((Abs(X2 - X1) ^ 2) + (Abs(Y2 - Y1) ^ 2))
in a function:
Public Function DistanceBetween(ByVal X1 As Single, ByVal Y1 As Single, ByVal X2 As Single, ByVal Y2 As Single) As Single
DistanceBetween = Sqr((Abs(X2 - X1) ^ 2) + (Abs(Y2 - Y1) ^ 2))
End Function
Still you will have some homework to define the measurement units.
You can use the Wifi-Library if you do not want to use Gps. The Wifi-Library gives you very exact positioning if you are near any router, else you will get positioning from the masts. It is very easy and straightforward to use.