Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android仿真器时间同步_Android_Time_Emulation_Synchronisation - Fatal编程技术网

android仿真器时间同步

android仿真器时间同步,android,time,emulation,synchronisation,Android,Time,Emulation,Synchronisation,是否有某种方法可以将模拟器时间和系统时间同步到毫秒精度?因此调用System.currentTimeMillis()将返回与C中调用gettimeofday()相同的时间?我不确定我是否100%理解了这个问题 如果查看dalvik/vm/native/java\u lang\u System.c,您将看到: static void Dalvik_java_lang_System_currentTimeMillis(const u4* args, JValue* pResult) { st

是否有某种方法可以将模拟器时间和系统时间同步到毫秒精度?因此调用
System.currentTimeMillis()
将返回与C中调用
gettimeofday()
相同的时间?

我不确定我是否100%理解了这个问题

如果查看
dalvik/vm/native/java\u lang\u System.c
,您将看到:

static void Dalvik_java_lang_System_currentTimeMillis(const u4* args, JValue* pResult)
{
    struct timeval tv;

    UNUSED_PARAMETER(args);

    gettimeofday(&tv, (struct timezone *) NULL);
    long long when = tv.tv_sec * 1000LL + tv.tv_usec / 1000;

    RETURN_LONG(when);
}
所以System.currentTimeMillis()调用gettimeofday()——至少在我所看到的dalvik实现中是这样


使用类似于在模拟器上设置时间的应用程序怎么样。它使用ntp协议,您也可以在主机PC上使用该协议。

不幸的是,Android没有时间由没有root的应用程序设置。所以你只能在你需要的时候设定时间