Automatic Date and Time

2

I'm developing an application on Android and would like to know if anyone knows of an open source application or knows about the code that verifies that the Automatic Date and Time (provided by the network) option is enabled on the device.

Thank you

    
asked by anonymous 08.04.2016 / 14:41

2 answers

1

I use 18, but the tip is, I found these codes

API 17 Up

android.provider.Settings.Global.getInt(getContentResolver(), android.provider.Settings.Global.AUTO_TIME, 0);

API 16 down

android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.AUTO_TIME, 0);
    
08.04.2016 / 18:52
1

To do this, use the AUTO_TIME .

Here is an example implementation:

   int type =0;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
           type =  Settings.Global.getInt(getContentResolver(), Settings.Global.AUTO_TIME, 0);
        }else{
           type =  Settings.System.getInt(getContentResolver(), Settings.System.AUTO_TIME, 0);
        }

If your return is 1 , then the option is enabled! Otherwise it returns 0 .

    
08.04.2016 / 20:17