Flutter OHOS system_boot_time(获取系统启动时间)
system_boot_time
获取系统启动时间
用法
import 'package:system_boot_time/system_boot_time.dart';
final second = await SystemBootTime().second();
鸿蒙 OS 代码
获取启动时间
复制代码
类型转换
复制代码
本文字数:571 字
阅读完需:约 2 分钟
获取系统启动时间
import 'package:system_boot_time/system_boot_time.dart';
final second = await SystemBootTime().second();
setup(binaryMessenger: BinaryMessenger, api: SystemBootTime | null): void {{ let channel = new BasicMessageChannel<Object>(binaryMessenger, "dev.flutter.pigeon.SystemBootTime.second", this.getCodec()); if (api != null) {channel.setMessageHandler({ onMessage(msg: Object, reply: Reply<Object>): void {let wrapped = new Map<string, string | number | Map<string, string | number>>();try { let systemBootTime = api.second(); wrapped.set("result", systemBootTime);} catch (exception) { let errorMap = new Map<string, string | number>(); errorMap.set("message", exception.message); errorMap.set("code", exception.name); errorMap.set("details", `Cause: ${exception.cause}, Stacktrace: ${exception.stack}`); wrapped.set("error", errorMap);}reply.reply(wrapped); }}); } else {channel.setMessageHandler(null); }} }
second(): number {return Math.floor(systemDateTime.getUptime(systemDateTime.TimeType.STARTUP, false) / 1000); }
还未添加个人签名 2024-10-29 加入
还未添加个人简介

促进软件开发及相关领域知识与创新的传播
京公网安备 11010502039052号 | 产品资质



评论