Can I have Location services turn itself off automatically after a certain time is reached (let's say 10 minutes)? I normally leave it off save for some applications (Maps, etc) but sometimes I forget to turn it off, and it's a big battery drain.
What I do here is creating a profile like this:
- Condition: App (select the apps you want to use GPS with)
- Task: GPS On
- optional exit task: GPS Off
That way GPS by default is off, but automatically gets turned on whenever you launch one of the selected apps and have them running in foreground. It would automatically be turned off once you exit that app, or have any other app running in foreground. The "exit task" is optional as Tasker restores the conditions from before the profile became active.
For other alternative automation apps, you're also welcome to take a look at my list here.
Edit: This answer is successfully tested on Android 4.2.1, without giving root access to AutomateIt. However, on Android 4.4.2, COS12 (Android 5.0.2) and CM12.1 (Android 5.1.1, build: YOG7DAO1K6), the relevant options were not visible until I restarted the app with root access. This fact came to my notice through this comment by jonatr.
- Install and launch AutomateIt.
- Go to My Rules → All, and see if you need any predefined rules. If you don't then either disable or delete by tapping each entry once and selecting the desired option.
+corresponding to My Rules tab → Application Status Trigger → tap lens icon and choose your app (Maps here) → check Application Activated→ Next → Enable/Disable GPS Action → Enable GPS → Next → choose Default or No (to show or not, a toast whenever automation will be triggered) → tap floppy icon at the top to save everything.
- Repeat steps 2-4 except that uncheck Application activated in step 3 this time.
Now you can open the Maps and Location will be enabled. You close the Maps and Location will be disabled. You can do more with it if you certainly want to disable Location (say 10 minutes) after minimizing the Maps.
Honestly, I'll prefer Tasker because I need fewer steps and I know it doesn't hog my battery. Check it out if AutomateIt eats the battery quite a lot.
As said, most automation apps can perform this task, Automate is another free alternative. Here's some user-made automations for toggling the GPS when viewing Google Maps:
A rooted device is required, but it may be possible to workaround using UI automation.
MacroDroid's free version can do it.
Edit: This answer is successfully tested on Android 4.2.1, without giving root access to MacroDroid. However, on Android 4.4.2, COS12 (Android 5.0.2) and CM12.1 (Android 5.1.1, build: YOG7DAO1K6), MacroDroid failed to complete the job without root access. This fact came to my notice through this comment by jonatr.
- When creating a macro choose the trigger Application Launched/Closed → Application Launch → select your app.
- Under Add Actions, tap GPS Enable/Disable → GPS On.
It may say so but it doesn't need root access.See edit above.
- Create another macro but make it for Application Closed and set GPS Off as the action.
That's it. Launch that selected app and GPS would activate automatically, close the app and GPS would deactivate.