Set Android's date/time programmatically

*爱你&永不变心* 提交于 2019-11-30 06:40:38
Praful Bhatnagar

The user application does not have permission to change the device time. Please read the answer by cashbash in the following post for the alternate option.

Copying here for quick reference:

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!