在Android和iPhone的总运行时间 [英] Total uptime on Android and iPhone

查看:125
本文介绍了在Android和iPhone的总运行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我知道,这两个操作系统让我获得自上次启动电流的正常运行时间,但有一种方式来获得总运行时间,因为该操作系统是第一次启动,或者因为我的应用程序安装或类似的东西?我想在开机运行的后台服务积累,对我,但事实证明我真的不能做,在iOS或东西。任何想法如何实现这一点?

As far as I know both OSes allow me to obtain the current uptime since the last boot, but is there a way to obtain the total uptime since the OS was first started, or since my application was installed or something like that? I was thinking of running a background service on boot to accumulate that for me, but turns out I can't really do that on iOS or something. Any ideas how this can be achieved?

推荐答案

在谈到Android的:

Speaking for Android:

是有办法获得总运行时间,因为操作系统首次启动

is there a way to obtain the total uptime since the OS was first started

不是直接的,但看到下面准的解决方法。

Not directly, but see below for a quasi-workaround.

或自从安装我的应用

软件包管理系统 getPackageInfo()可以返回你一个 PackageInfo 对象一些包,比如你自己的包名。这有一个长firstInstallTime 将指示安装软件包时。

PackageManager and getPackageInfo() can return you a PackageInfo object for some package, such as your own package name. That has a long firstInstallTime that will indicate when the package was installed.

因为你可以得到 PackageInfo 反对任何包,欢迎您煮了一些算法,试图接近首次使用该设备时,通过查找最古老的应用程序的时间安装。但是,你必须过滤掉pre-安装的应用程序,这将变得棘手。我当然不希望依靠这一点。

Since you can get PackageInfo objects for any package, you're welcome to cook up some algorithm to try to approximate the time the device was first used, by finding the time of the oldest app install. However, you'd have to filter out pre-installed apps, and that will get tricky. I certainly would not want to rely upon this.

这篇关于在Android和iPhone的总运行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆