How to retrieve provider time in Android programmatically?
I am doing an android app which has to display the current server/network operator time since the device time can be changed by the user. I don't want to change/set the device time. I tried few source codes but they didn't work well. I'm able to get device date and time but I need date and time from server or network provider itself. please help me
It seems that you need to interface with the Network Time Protocol (NTP).
As noted in the comments of these posts, as of Honeycomb you cannot do any network operations in the main activity thread (suggestion: use a service instead).
A further search led me to find Dominik Schürmann's ntp-sync repository on GitHub. He provides different examples of how you can use his library which you can compile and run on your emulator/device.
I had found a solution but forgot to post it. In case somebody finds it helpful, here is what worked for me.
Get the server time using an API or network call wherein the response will have the timestamp from the server. Use the data as per your convenience.
You can modify the existing API itself, if any.