android 获取所有app的安装时间

    fun getAllPackageInstallTime() {
        try {
            val packageInfos = packageManager.getInstalledPackages(0);
            for (i in packageInfos) {
                if (ApplicationInfo.FLAG_SYSTEM == i.applicationInfo.flags) {
                    continue
                }
                val packageManager = applicationContext.packageManager
                val packageInfo = packageManager.getPackageInfo(i.packageName, 0)
                val firstInstallTime = packageInfo.firstInstallTime
                val lastUpdateTime = packageInfo.lastUpdateTime
                Log.d("ccccccc", "first install time : $firstInstallTime last update time :$lastUpdateTime")
            }
        } catch (e: PackageManager.NameNotFoundException) {
            e.printStackTrace()
        }
    }

你可能感兴趣的:(android 获取所有app的安装时间)