aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt
index 538208d..ebd7161 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt
@@ -1,8 +1,12 @@
package ca.allanwang.kau.utils
+import android.content.ActivityNotFoundException
import android.content.Context
+import android.content.Intent
import android.content.pm.PackageManager
+import android.net.Uri
import android.os.Build
+import android.provider.Settings
/**
* Created by Allan Wang on 2017-06-23.
@@ -30,6 +34,20 @@ import android.os.Build
}
}
+@KauUtils fun Context.showAppInfo(packageName: String) {
+ try {
+ //Open the specific App Info page:
+ val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
+ intent.data = Uri.parse("package:$packageName")
+ startActivity(intent)
+ } catch (e: ActivityNotFoundException) {
+ e.printStackTrace()
+ //Open the generic Apps page:
+ val intent = Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS)
+ startActivity(intent)
+ }
+}
+
inline val buildIsMarshmallowAndUp: Boolean
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M