2011-01-31 30 views
4

是否有某種方法可以以毫秒的精度同步仿真器時間和系統時間?所以電話System.currentTimeMillis()將返回與C中的電話號碼gettimeofday()相同的時間?android模擬器時間同步

回答

0

我不確定我是否理解100%的問題。

如果您在dalvik/vm/native/java_lang_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執行至少。

如何使用像ClockSync這樣的應用程序來設置仿真器上的時間。它使用ntp協議,您也可以在主機上使用該協議。

0

不幸的是,Android沒有notallow時間由沒有根的應用程序設置。因此,只有在root the emulator的情況下,您才能設置時間。