Android provides you with APIs, that you can easily integrate with your application, GPS is one of them. Typically, you consume those services, from the API contracts, unless you have an API built on your own server, a web application, etc. If not, consume Google provided APIs. Nowadays, you would look for Firebase, or Google Play Services for these GPS services.
I wrote an article, that gives a complete overview of GPS;
Ok Android, Broadcast my location![
^], although uses an old API but explains the concept in a proper detail.