Get Geolocation When App Not In Use

I want to get user location when the user does not use the app.

Is there a way to make this app run all the time and get the GPS location?

Please help me in this.