如何更新的Andr​​oid时间 [英] How to update the android time

查看:135
本文介绍了如何更新的Andr​​oid时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我采用了android TAB对于一些应用程序开发。
在我的应用我得到UTC时间从其他应用程序(其他设备通过TCP套接字提供了我的应用程序)。有一次,我收到这个我需要得到时间来更新时间。有没有API来更改系统时间..?


解决方案

 公共静态布尔setCurrentTimeMillis(long millis)来

设定当前挂钟时间,以毫秒为单位。 需要调用进程具有相应的权限。 [虽然只有系统进程可以更改时间]

用户的应用程序无法设置时间。只有系统进程。这是
对于
安全性,而且还因为我认为它不会有太大的effect--时间确实从重置
通过网络时间收音机。

参考链接

I am using android TAB for some app development . in my application I get UTC time from the other application(other device provides to my application via TCP socket ) . Once I receive this I need to update the time with receive time . Is there any apis to change the system time ..?

解决方案

public static boolean setCurrentTimeMillis (long millis)

Sets the current wall time, in milliseconds. Requires the calling process to have appropriate permissions. [although Only system process can change the time]

User apps cannot set the time. Only the system processes can. This is for security, but also because I think it won't have much effect-- the time does reset from the radio via network time.

reference link

这篇关于如何更新的Andr​​oid时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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