让用户更改时间的Android [英] Making the user change the time in Android
问题描述
Android不出现,以提供一种适合于<一href="http://stackoverflow.com/questions/1332269/how-to-set-mobile-system-time-and-date-in-android">user应用程序更改系统时间。我想这样做反而是让用户更改时间。这是很容易打开日期和放大器;时间设置:
startActivity(新意图(android.provider.Settings.ACTION_DATE_SETTINGS));
我想知道的是:
- 是否有可能直接链接到设定的时间选项?
- 是否可以检查用户设置正确的时间?我知道了
TIME_CHANGED
广播消息的,但我不能找到它 任何文件
更新:
在TIME_CHANGED广播消息未提供有关它如何变化的任何信息。这是没有明确记载,但我试过的getData code>和
getExtras
并没有收到任何信息。另外,在看的<一个休息href="http://stackoverflow.com/questions/2808325/documentation-for-extra-in-intents-for-android">documentation它似乎没有数据或额外传递,除非明确记载。同样的,它实际上是记录中的 ACTION_DATE_SETTINGS
概不投入,这是隐含的,它需要没有额外,所以没有办法控制它更precisely。
<一个href="http://stackoverflow.com/questions/2799761/making-the-user-change-the-time-in-android/2802321#2802321">CommonsWare指出什么应该是显而易见的我 - 简单地检查用户设定的时间从服务器检索到的值,而不用担心在选项菜单中所花费的时间,几乎总是工作。由于这个假设实际上可能是假的,如果我使用这种方法,那么我会确保消息说,时间的也许的设置是否正确或错误,而不是使用一个明确的说法。
不过,我发现 elapsedRealtime 并所以我将真正实现这种检测正常。
时,可以直接链接到 设定时间的选择吗?
尝试:
startActivity(新意图(android.provider.Settings.ACTION_DATE_SETTINGS));
时可以检查用户 设置时间是否正确?
::耸肩::
在应用再次获得控制,检查的时间。
Android doesn't appear to provide a way for a user application to change the system time. What I would like to do instead is to get the user to change the time. It is easy to open up the Date & Time settings:
startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));
What I would like to know is:
- Is it possible to link directly to the set time option?
- Is it possible to check that the user set the time correctly? I am aware of the
TIME_CHANGED
broadcast message, but I can't find any documentation on it
Update:
The TIME_CHANGED broadcast message doesn't provide any information about how it changed. This isn't explicitly documented, but I tried getData
and getExtras
and received no information. Additionally, looking at the rest of the documentation it appears that no data or extras are passed unless explicitly documented. Similarly, it is actually documented the ACTION_DATE_SETTINGS
takes no input and it is implicit that it takes no extras, so there is no way to control it more precisely.
CommonsWare pointed out what should have been obvious to me - that simply checking that the user set the time to the value retrieved from the server, without worrying about the time spent in the options menu, will almost always work. As this assumption could actually be false, if I were using this method, then I would ensure the message said that the time was probably set correctly or incorrectly, rather than using a definite statement.
However, I discovered elapsedRealtime and so I will actually implement this detection properly.
Is it possible to link directly to the set time option?
Try:
startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));
Is it possible to check that the user set the time correctly?
:: shrug ::
After the application gets control again, examine the time.
这篇关于让用户更改时间的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!