This can also be done if you install the “application” on the device you want to track, which contains a broadcast receiver that is triggered by a certain event (that is, an SMS message with a specific “code” in the message). you could then get your location (network or GPS, if possible) and return that value back to you.
Everything can happen in the background, provided that the application is installed. The application does not need to be launched.
Even if it is possible, it crosses a lot of gray lines :-)
source
share