Save State


These tasks will save the state of the device before you run a task and then restore that state after your tasks. For example, if you create a profile to temporarily mute the sound, you can restore the sound volume to it's previous level.

To use these tasks simply run "Save All Vars" task to save the device state, and then run "Restore All Vars" when you want to restore the state. Some states requires the "Secure Settings" plugin or a rooted phone. If you don't have that, you can easily remove those capabilities from these tasks.

Task descriptions:

  • Save All Vars - This task saves tasker variables into an array. There are 19 variables saved. If you don't want to save/restore all the capabilities, just remove them from this task. For each capability, there are two "Array Push" statesments that should be removed, one for name and one for value.
  • Restore All Vars - This task reads the capabilities from the save array and restores them all. Whatever state you have saves in the "Save All Vars" task will be restored by this task.
  • Restore % - Each capability has a corresponding task that resets the state. There are 19 of them.
  • Test Save/Restore - A task I used to test that each state was being reset correctly.

How to:

  • Save/Restore All Capabilities
    • Run "Save All Vars" task to save the device state
    • When you want to restore the state, run "Restore All Vars"
  • Save/Restore One or Some Capabilities
    • Clone "Save All Vars" task.
    • Edit cloned task and removed unwanted capabilities from the "Array Push" statements.
    • Run cloned task to save the device state
    • When you want to restore the state, run "Restore All Vars"
  • Add new capability (if I missed something)
    • Create "Restore [VAR NAME]" task that executes the actions needed to reset a state. [VAR NAME] must be the exact Tasker variable name that contains the state.
    • Edit "Save All Vars" and add two new "Array Push" statements with the name/value of the state variable.
    • "Restore All Vars". No changes are needed to this task.
  • Test Save Restore.
    • Run "Save All Vars".
    • Change any state. This can be with your own profile/task or you could just change it using the phone.
    • Run "Restore All Vars".
    • Run "Test Save/Restore". This will compare the before/after state variables.

Make sure that a 2nd save/restore runs over another save/restore or the state array will get updated by the 2nd task. You could create multiple arrays if this is needed. (If you are a programmer, this should make sense)

If you want to test these tasks, "Restore All Vars" and "Test Save/Restore" cannot be run from within tasker. Each calls child tasks that need to run sequentially. I discovered that running tasks from within Tasker gives them a priority of 10 and so parent/child tasks all run in parallel. Create a Tasker shortcut for "Restore All Vars" and "Test Save/Restore" and run them outside of Tasker.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License