this is inter process communication. the main method for IPC in android is to use services, see https://developers.android.com/guide/components/processes-and-threads.html#IPC
https://developers.android.com/guide/components/bound-services.html#Binding
you can run Service
or IntentService
in background and then bind (bindService()
) or unbind (unbindService()
) to the service when you need the GPS location
an example to use the internal GPS in background using the android system [!] service LocationListener
is in http://www.stackoverflow.com/questions/28535703/best-way-to-get-user-gps-location-in-background-in-android
you have to do this differently because your service is not a system service
so write a background GPS service (this is what google says is best practice, i would use Service instead of IntentService -> https://developers.android.com/training/best-background.html) then your (self-written) applications can bind to the GPS service to get the data. You have to start the service in some app or at boot up
a very good binding example is http://www.stackoverflow.com/questions/4300291/example-communication-between-activity-and-service-using-messaging
normally external GPS implement USB CDC class so you should see it in /dev/tty(USB | ACM ,...)
this is how you can communicate with it or you check if it has events in /dev/input/eventx
(need root for this)