Is there way to track the location only during a small predefined time window? I'm looking for an way for an Android phone to record (preferably locally on the device) its GPS position (10-20m accuracy) with a pretty high frequency (e.g. every minute or every 30secs) but ONLY during pre-set time windows, e.g. weekdays between 7:30-8:00 and 13:15-13:45. The rest of the time I want it to do nothing and use no resources.
You can use a combination of Macrodroid and GPS logger for Android to automate the logging process.

Step 1: install apps and configure GPS logger


Install GPS logger for Android and Macrodroid.
Open GPS logger. Give the necessary permissions. Tap the menu, then General options. Select Start app on launch. 


Step 2: macro to launch the app


Start Macrodroid, click on Add macro.
In the Triggers tab, select Date/time trigger. Set the day(s) and time when it should run. Click ok.
In the Actions tab, in the Applications section, select Launch application, select GPS logger. Select Exclude from recent apps.
In the Actions tab, in the Device actions section, select Press back, give the appropriate permission, go back select Press back.
Save the macro and give it a name. It will look like the image below.




Step 3: macro to stop the app


Still using Macrodroid, click on Add macro.
In the Triggers tab, select Date/time trigger. Set the day(s) and time when the macro should run and stop the app. Click ok.
In the Actions tab, in the Applications section, select Launch application, select GPS logger. Select Exclude from recent apps.
In the Actions tab, in the Macrodroid specific section, select Wait before next action, set it to 2-3 seconds.
In the Actions tab, in the Applications section, select UI interaction. Give the appropriate permission Go back select UI interaction, select Identify in app. Open GPS logger, click the Macrodroid UI notifications on the status bar, then click the Stop logging button of GPS logger. 
In the Actions tab, in the Device actions section, select Press back.
In the Actions tab, Applications section, select Kill background process, select GPS logger.
In the Constraints tab, in Device state section, select Application running, give the appropriate permission. Go back to the macro, select Application running, select Alive in background
Save the macro and give it a name. It will look like the image below.




The first macro starts the app  at the selected days and time while the second stops it by pressing the Stop logging button, then kill it from running in the background at the selected days and time. Make sure that in step 5 of the second macro, Stop logging is selected and not Start logging. If when selecting Stop logging, Start logging is instead selected, then select Start logging instead of Start logging.