views:

700

answers:

4

When you want to change the mobile system date or time in your application, how do you go about doing it?

A: 

Does anybody konws?

A: 

when i get a Date from a DatePickerDialog,so ,i want to set the system Date to coresponding with to the changed Date.

A: 

If I'm reading it right the SystemClock class will do it... specifically the setCurrentTimeMillis(long) method.

fiXedd
well,i have tried your propose, but it is likely that will not change the system time...
Oh well, sorry.
fiXedd
According to [this thread](http://groups.google.com/group/android-developers/browse_thread/thread/855ae4fe695d3e70), user apps cannot set the time, regardless of the permissions we give it
Casebash
A: 

According to this thread, user apps cannot set the time, regardless of the permissions we give it. Instead, the best approach is to make the user set the time manually. We will use:

startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));

Unfortunately, there is no way to link them directly to the time setting (which would save them one more click). By making use of ellapsedRealtime, we can ensure that the user sets the time correctly.

Casebash