Getting GPS coordinates for the first time (if the GPS service isnβt working) can be a time-consuming process because GPS needs to be initialized a lot. Dismissing the first onLocationChange is an Android GPS way of saying, "I know where I am now." Therefore, you may have to figure out a way to work with onLocationChange.
The way you use your SMS / GPS API on demand is to keep the GPS service running . Have you studied / tried this? You can also wait for your SMS process until the GPS location is available, until there is a certain amount of time to wait for a timeout of a reasonable length, and then send an SMS message. And subsequent queries should go much faster since you initialized your GPS. In any case, you cannot count on lat / long from the GPS service in real time.
Here is a great article on mobile GPS . This is common, but reading through it will show the reasons why you cannot just get GPS readings βat the click of a button."
source share