Contact stuff

This commit is contained in:
MM20
2025-04-04 18:16:16 +02:00
parent 0ebce91a43
commit 04dd12ee96
7 changed files with 141 additions and 73 deletions
@@ -0,0 +1,26 @@
package de.mm20.launcher2.ktx
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.graphics.drawable.Drawable
fun PackageManager.getApplicationInfoOrNull(
packageName: String,
flags: Int = 0,
): ApplicationInfo? {
return try {
getApplicationInfo(packageName, flags)
} catch (e: PackageManager.NameNotFoundException) {
null
}
}
fun PackageManager.getApplicationIconOrNull(
packageName: String,
): Drawable? {
return try {
getApplicationIcon(packageName)
} catch (e: PackageManager.NameNotFoundException) {
null
}
}