m4f1050
m4f1050

Reputation: 103

Android - change Date/Time setting's 24-hour switch to off

After reading this:

12/24-hour mode conflict

I am a bit confused. Can someone please help me with this?

Here is my situation: I have a Chinese MCU radio and with stock ROM or a custom ROM. I set my locale to Eastern Time. So it's US, but the 24-hour switch doesn't seem to be affected when selecting the locale, so it's just picking one randomly? Even after I change the time format 24-hour to OFF, after a few restarts, it occasionally changes to ON and the time is show in 24-hours everywhere.

Here is my question:

How can I check what the setting is at the moment of running my app, and if it's ON, how do I switch it to OFF or vice-versa?

Upvotes: 0

Views: 1524

Answers (1)

m4f1050
m4f1050

Reputation: 103

I guess I should've checked developer.android.com

I had to set on the Manifest the permission WRITE_SETTINGS

then:

    if (DateFormat.is24HourFormat(this))
    {
        Settings.System.putString(this.getContentResolver(), Settings.System.TIME_12_24, "12");
    }

This is only to set it to 12-hour format, but you get the idea.

Upvotes: 2

Related Questions