如何更改Android上的日期,编程? [英] How to change the date on android, programmatically?

查看:158
本文介绍了如何更改Android上的日期,编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

,因为它可能是需要运行基于日期和时间的应用程序的测试非常有用,它可以很好的创造了Android的桌面上的部件/快捷方式,通过一个单一的点击跳过几个小时/天/ ...

since it could be useful for testing of apps that need to run based on dates and time, it could be nice to create a widget/shortcut on the "desktop" of android, and by a single click to skip a few hours/days/...

我不认为有这样使用正常API的事情。唯一的类似的事情是使用意图打开日期的选择。

i don't think there is such a thing using the normal API. the only similar thing is to use an intent to open the date options.

有没有可能使用的Andr​​oid API来做到这一点?如果没有,是否有可能用ROOT办呢?怎么样?

is it possible to do it using the API of android? if not, is it possible to do it using ROOT? how?

编辑:我已经找到一种方法使用根的 这里 ,但我无法找到正确的参数和文件如何使用它(该链接是不是该参数为Android正确的)。

i've found a way to do it using root, here , but i can't find the correct parameters and documentation of how to use it (the link isn't correct about the parameters for android).

推荐答案

您并不需要以root您的设备,只需使用下面的code,

You don't need to root your device, just use following code,

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

另一个方法是使用 SystemClock 类的setCurrentTimeMillis(长米利斯)方法。

The another way is by using SystemClock class's setCurrentTimeMillis(long millis) method.

这篇关于如何更改Android上的日期,编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆