Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.net.SntpClient is missing from Android SDK

I am trying to get time from an Internet Time Server. And I found that android.net.SntpClient is a good solution that I could use.

But my Android SDK (Android API 19) does not contain that class. I downloaded the "Sources for Android SDK" via SDK Manager and the source code contains the SntpClient.java (source file for class android.net.SntpClient)

Please view the images links I uploaded. (sorry, I dont have enough reputation for images right here)

The android SDK: https://scontent-a-sea.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/s720x720/1888504_897281990284152_2310291065247680835_n.jpg?oh=989c5f49848a8914d77bb0d4aac8897d&oe=54F8E9D6

The sources: https://scontent-a-sea.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/s720x720/10659310_897281993617485_1823842706987095742_n.jpg?oh=27ee6a075967731dc7265352c22002cd&oe=54DCBB73

Could anyone tell me why this file is not compiled? If I want to use this class, I have to explain to my boss why android SDK doesn't contain it.

Thanks a lot

like image 510
Nguyễn Đức Huy Avatar asked Mar 13 '26 09:03

Nguyễn Đức Huy


1 Answers

Google has chosen not to make all public classes available as part of the SDK. Visibility is controlled by the @hide comment tag as described here.

I'm not sure why they chose to hide SntpClient particularly, but provided you respect the terms of the Apache license you can copy the source into your application without much modification.

like image 61
Rupert Rawnsley Avatar answered Mar 14 '26 23:03

Rupert Rawnsley