查看所有安装的App信息
val apps = {
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_LAUNCHER)
context.packageManager.queryIntentActivities(intent, 0).map {
val info = it.activityInfo
val label = info.loadLabel(context.packageManager)
val icon = info.loadIcon(context.packageManager)
val packageName = info.packageName
val className = info.name
AppInfo(label, icon, packageName, className)
}
}
data class AppInfo(
val label: CharSequence,
val icon: Drawable,
val packageName: String,
val className: String
)