Klapsius
Klapsius

Reputation: 3359

Time synchronisation on Android devices

I have 100+ android devices on a network. These devices constantly loosing time (time is not accurate +- few hours or sets to default date time 2010 ... 00:00 ) and I would like to synchronise time and date with android NTP. I can't root those devices. These devices are on a network without internet. I believe only one solution is to create exception in our firewall to allow devices to connect to android NTP server??? How can I find this URL. Is it another option so sync date time?

Upvotes: 0

Views: 1673

Answers (1)

aolphn
aolphn

Reputation: 2998

To get internet time by following code snippet:

public long getInternetTime() {
    SntpClient client = new SntpClient();
    if (client.requestTime("time.nist.gov", 10000)) {
        long time = client.getNtpTime();
        return time;
    }
    else {
        Log.e(TAG, "get internet time failed");
    }
    return -1;
}

Upvotes: 2

Related Questions