Changing system Date or time from my Application

quaker

Member
Licensed User
Longtime User
HI all

is there any way to change system date/system time from a user application using basic for android?

I have seen that using java is possible using this thread:

Short Answer

It's possible and has been done. You need android.permission.SET_TIME. Afterward use the AlarmManager via Context.getSystemService(Context.ALARM_SERVICE) and it s method setTime().

Snippet for setting the time to 2010/1/1 12:00:00 from an Activity or Service:

Calendar c = Calendar.getInstance();
c.set(2010, 1, 1, 12, 00, 00);
AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
am.setTime(c.getTimeInMillis());


If you which to change the timezone, the approach should be very similar (see android.permission.SET_TIME_ZONE and setTimeZone)

source:How to set mobile system time and date in android? - Stack Overflow
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…