9

I would like to be able to turn the automatic date time settings on and off from tasker. I don't see a way to do this directly but I can use tasker to issue a shell command. I know I can just use the date command to change the date to some specific date but is there a way to turn the automatic setting off and on from a command line or tasker?

1
  • If your problem is incorrect DST info - you can just update timezone database. Commented Jun 21, 2013 at 10:33

2 Answers 2

5
+50

It might be useful to check the android source to find the exact package name to the system settings, specifically this source responsible for date/time, line 226 is the key!

Have played with tasker before, but can tasker directly modify system properties? as in directly do this, I am quoting line 228 the pertinent part:

Settings.Global.putInt(
        getContentResolver(), 
        Settings.Global.AUTO_TIME_ZONE, 
        autoZoneEnabled ? 1 : 0);

In short the actual direct name to the package would be com.android.settings/.DateTimeSettings, if that's of any help!

By using adb shell's Android Activity Manager, am, one can start the activity to go directly into that screen as in am start -n com.android.settings/.DateTimeSettings, experiment and see if that fits your needs as I have not actually played with it. :)

2
  • There is also a Settings.Global.AUTO_TIME settings that you can also disable for auto date & time. Commented Sep 5, 2017 at 14:45
  • The setting wasn't working for me on Android10/Q but this method worked: stackoverflow.com/a/68055904/573377 DevicePolicyManager dpm = (DevicePolicyManager) getApplicationContext().getSystemService(Context.DEVICE_POLICY_SERVICE); ComponentName component = new ComponentName(getApplicationContext(), DeviceAdminReceiver.class); dpm.setGlobalSetting(component, Settings.Global.AUTO_TIME, enable ? "1" : "0");
    – jeoffman
    Commented Aug 4, 2021 at 18:41
9

turn on:

settings put global auto_time 1

turn off:

settings put global auto_time 0

source: Android sourcecode

1
  • 1
    An example using ADB would be: $ adb shell settings put global auto_time 1 Commented Mar 31, 2021 at 23:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .