首页 \ 问答 \ vala:这是以毫秒为单位获取当前时间的正确方法吗?(vala: is this the correct way to get the current time in milliseconds ?)

vala:这是以毫秒为单位获取当前时间的正确方法吗?(vala: is this the correct way to get the current time in milliseconds ?)

与Vala一起使用这个库:

http://valadoc.org/#!api=glib-2.0/GLib.DateTime

    GLib.DateTime now = new GLib.DateTime.now_local();

    var sec = now.to_unix()
    var msec = (sec * 1000) + now.get_microsecond();

这是以毫秒为单位获取当前时间的正确方法吗?

有没有更好的办法 ?


Using this library with Vala :

http://valadoc.org/#!api=glib-2.0/GLib.DateTime

    GLib.DateTime now = new GLib.DateTime.now_local();

    var sec = now.to_unix()
    var msec = (sec * 1000) + now.get_microsecond();

is this the correct way to get the current time in millisecond ?

is there a better way ?


原文:https://stackoverflow.com/questions/19467849
更新时间:2023-07-05 21:07

最满意答案

好的,最后我自己得到了答案......

我们在这个问题上遇到的第一件事是在执行模拟器时得到以下警告。

警告:SD卡文件必须至少为9MB,忽略/ dev / sdX

跟踪main.c中的源代码后,

   if (size < 9*1024*1024ULL) {
           fprintf(stderr, "### WARNING: SD Card files must be at least 9MB, ignoring '%s'\n", opts->sdcard);
        } else {
            hw->hw_sdCard_path = ASTRDUP(opts->sdcard);
        }

我忽略了if条件,即强制执行hw-> hw_sdCard_path = ASTRDUP(opts-> sdcard);

一切顺利:)


OK, finally I got the answer by myself...

first thing we occured in this issue is got below warning when execute emulator.

WARNING: SD Card files must be at least 9MB, ignoring /dev/sdX

after traced the source code in main.c,

   if (size < 9*1024*1024ULL) {
           fprintf(stderr, "### WARNING: SD Card files must be at least 9MB, ignoring '%s'\n", opts->sdcard);
        } else {
            hw->hw_sdCard_path = ASTRDUP(opts->sdcard);
        }

I ignored the if condition, i.e. force execute hw->hw_sdCard_path = ASTRDUP(opts->sdcard);

then, everything go right:)

相关问答

更多
  • SD卡(外部存储) 可移动存储不是外部存储 。 我在清单文件中添加了权限 这些权限与可移动存储无关。 我收到了这个错误 您没有直接文件系统访问可移动存储上的任意位置。 你知道如何允许访问EXTERNAL SD CARD吗? 或者: 在Android 4.4+上,在Android 4.4+上使用getExternalFilesDirs() , getExternalCacheDirs()和/或getExternalMediaDirs() (注意方法名称的复数形式),以便在可移动存储上访问应用程序的唯一目录。 ...
  • 问题在于启动模拟器时的命令行参数 〜/ sdcard256m.img 我不得不扩展“ 〜 ”并将其更改为 /home/username/sdcard256m.img 在模拟器中检测到SD卡,我能够通过DDMS文件资源管理器推送文件。 The problem was with the command line parameter while launching the Emulator ~/sdcard256m.img I had to expand "~" and changed it to /home/u ...
  • 在avd目录中,它位于以下位置: 视窗: %USERPROFILE%.android \ AVD \ 有一个名为sdcard.img的文件。 你可以用新的图像文件替换它。 你可以在android-sdk / tools中使用mksdcard创建一个新的SD卡图像文件 用法:mksdcard [-l label] In the avd directory, which is in the following location: Windows: %use ...
  • 相机可以将图像(或缓存图像)保存在SD卡中。 如果您想测试相机是否需要SD卡(通常不需要),请删除SD卡选项。 否则,我认为你可以通过以下方式尝试创建新的SD卡: 按Or create new image 输入150MB用于新SD卡 好的,再试一次。 Camera may save image (or cached image) in SDcard. If you want to test Camera needs SDcard or not (normally not), remove the SDCar ...
  • 好的,最后我自己得到了答案...... 我们在这个问题上遇到的第一件事是在执行模拟器时得到以下警告。 警告:SD卡文件必须至少为9MB,忽略/ dev / sdX 跟踪main.c中的源代码后, if (size < 9*1024*1024ULL) { fprintf(stderr, "### WARNING: SD Card files must be at least 9MB, ignoring '%s'\n", opts->sdcard); } else { ...
  • 您可以在创建AVD时指定SD卡。 或者,您可以在Eclipse运行配置 - 目标选项卡 - 其他仿真器命令行选项中指定-sdcard选项。 http://developer.android.com/guide/developing/tools/emulator.html#sdcard You can specify SD card when creating AVD. Or you can specify -sdcard option in Eclipse Run Configuration - Targe ...
  • 你在Eclipse中构建? 您需要在清单文件中设置目标SDK版本(如您引用的帖子所示),还需要在Eclipse的Project设置中进行设置。 在主菜单上,转到项目 - >属性 选择Android页面 选中您要构建的目标SDK旁边的框 您应该在Package Explorer中看到正确的Android版本作为库。 我在“src”和“gen”文件夹下面列为“Android2.2”。 Are you building within Eclipse? You need to set the target SDK ...
  • 请粘贴您的清单以及访问SDCard,您必须使用Environment.getExternalStorageDirectory()因为/mnt/sdcard/将是一个硬编码的解决方案,可能无法在某些设备或Android构建上工作。 Please paste your manifest and also for accessing the SDCard you must use Environment.getExternalStorageDirectory() since /mnt/sdcard/ would ...
  • 首先,尝试使SD卡更大 - 例如,100 MB - 并重新启动模拟器。 硬件部分IIRC中的布尔值触发应用程序的APK - 内部存储器或SD卡的首选位置。 一个9MB的APK并不罕见。 First, try making the SD card larger - like, 100 MB - and restarting the emulator. The boolean in the hardware section, IIRC, triggers the preferred location for t ...
  • 这在仿真器文档中有介绍 。 模拟的SD卡映像是模拟器读取和写入的单个文件。 您可以指定在使用android GUI创建Android虚拟设备(AVD)时创建SD卡(例如,在Eclipse中通过单击 按钮): 或者您可以使用mksdcard命令创建一个SD卡。 要在启动模拟器时使用SD卡映像,请将-sdcard选项传递给emulator命令: emulator -sdcard c:/path/to/my/sdcard 如果您使用android GUI启动仿真器,则需要在创建AVD时指定SD卡。 This i ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)