一种获取离线操作时间的方法、装置及电子设备制造方法及图纸

技术编号:18367029 阅读:86 留言:0更新日期:2018-07-05 07:50
本发明专利技术公开了一种获取离线操作时间的方法、装置及电子设备,该方法包括:获取登录应用软件时刻对应的系统时钟数,作为登录系统时钟数;获取登录应用软件时刻的服务器时间;获取离线操作应用软件时刻对应的系统时钟数,作为离线系统时钟数;根据服务器时间、登录系统时钟数和离线系统时钟数确定离线操作时间。通过本发明专利技术的获取离线操作时间的方法,在系统联网的情况下登录过应用软件,即使是在离线状态下或者是长时间停留在后台、甚至程序被退出,强制关闭之后情况下,应用软件获取的所有离线操作时间都是准确时间,而不会是修改之后的手机系统时间。防止用户在登录应用软件之后,关闭网络避免同步服务器时间来对时间作弊的问题。

Method, device and electronic device for obtaining off-line operation time

The invention discloses a method, a device and an electronic device for obtaining the offline operating time. The method includes obtaining the number of system clocks corresponding to the login application software, as the number of the login system clock, obtaining the time of the server time of the login application software, and obtaining the system clock corresponding to the offline operating software. Number is used as the number of offline system clocks, and the off-line operation time is determined according to server time, the number of logon system clock and the number of offline system clocks. Through the method of obtaining off-line operation time of the invention, the application software is logged in under the condition of the system networking. Even if it is in the off-line state or stay in the background for a long time, even the program is withdrawn, after the forced closure, all off-line operation times obtained by the application software are accurate time, but not It's the time to change the mobile phone system. It prevents users from closing the network after logging in to the application software, avoiding the problem of cheating time by synchronizing server time.

【技术实现步骤摘要】
一种获取离线操作时间的方法、装置及电子设备
本专利技术涉及计算机
,更具体地,涉及一种获取离线操作时间的方法、装置及电子设备。
技术介绍
应用软件APP用户在有网络的情况下登录APP之后,将程序退入后台,然后关闭手机网络并且修改手机的系统时间,重新进入应用将数据进行离线提交,此时客户端的时间为修改后的系统时间,并且由于没有网络,无法通过同步服务器时间,从而达到时间作弊的目的。目前比较常用的一种解决方案是:提交数据时,先通过同步服务端数据来获取正确的时间,然后再提交数据到服务端。但是这种解决方案的缺点是必须是有网络,无法离线提交操作时间。另一种解决方案是在第一次登录的时候,因为是有网络的情况下,所以获取服务端的时间,然后手机端设置一个定时器来计数,提交数据时,使用获取的服务端时间+定时器的计数值,得到准确的时间。但是这种方案缺点是基于IOS系统的应用软件如果长时间停留在后台,计数器会进入沉睡状态暂停,从而导致时间不准确。基于安卓系统的应用软件长时间停留在后台也有被系统强制关闭的可能,导致定时器被关闭,再次打开APP如果没有网络就无法确保获取到正确时间。专利技术内容本专利技术的一个本文档来自技高网...
一种获取离线操作时间的方法、装置及电子设备

【技术保护点】
1.一种获取离线操作时间的方法,其特征在于,包括:获取登录应用软件时刻对应的系统时钟数,作为登录系统时钟数;获取所述登录应用软件时刻的服务器时间;获取离线操作所述应用软件时刻对应的系统时钟数,作为离线系统时钟数;根据所述服务器时间、所述登录系统时钟数和所述离线系统时钟数确定离线操作时间。

【技术特征摘要】
1.一种获取离线操作时间的方法,其特征在于,包括:获取登录应用软件时刻对应的系统时钟数,作为登录系统时钟数;获取所述登录应用软件时刻的服务器时间;获取离线操作所述应用软件时刻对应的系统时钟数,作为离线系统时钟数;根据所述服务器时间、所述登录系统时钟数和所述离线系统时钟数确定离线操作时间。2.根据权利要求1所述的方法,其特征在于,所述获取登录应用软件时刻对应的系统时钟数,作为登录系统时钟数包括:在IOS系统下,获取登录应用软件时刻对应的mach_absolute_time函数的返回值,作为所述登录系统时钟数;在安卓系统下,获取登录应用软件时刻对应的SyetemClock.elapsedReaktimeNanos函数的返回值,作为所述登录系统时钟数。3.根据权利要求1所述的方法,其特征在于,所述根据所述服务器时间、所述登录系统时钟数和所述离线系统时钟数确定离线操作时间包括:计算所述离线系统时钟数与所述登录系统时钟数之间的差值;根据所述服务器时间和所述差值确定所述离线操作时间。4.根据权利要求1所述的方法,其特征在于,所述获取离线操作所述应用软件时刻对应的系统时钟数,作为离线系统时钟数包括:在IOS系统下,获取离线操作所述应用软件时刻对应的mach_absolute_time函数的返回值,作为所述离线系统时钟数;在安卓系统下,获取离线操作所述应用软件时刻对应的SyetemClock.elapsedReaktimeNanos函数的返回值,作为所述登录系统时钟数。5.一种获取离线操作时间的装置,其特征在于,包括:第一获取模块,用于获取登录应用软...

【专利技术属性】
技术研发人员:丁明胡贝郭海球
申请(专利权)人:广州市玄武无线科技股份有限公司
类型:发明
国别省市:广东,44

网友询问留言 已有0条评论
  • 还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。

1