aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-11-13 04:51:43 -0500
committerAllan Wang <me@allanwang.ca>2017-11-13 04:51:43 -0500
commit1bc48a6b4b43833321eaeb544ce324cf8ffcefa6 (patch)
tree28c15ed13179b1a59f53e99c3ff577e42a390fb5 /core/src
parent1b7368f89500b16d5a7a16db9dc01778bed92194 (diff)
downloadkau-1bc48a6b4b43833321eaeb544ce324cf8ffcefa6.tar.gz
kau-1bc48a6b4b43833321eaeb544ce324cf8ffcefa6.tar.bz2
kau-1bc48a6b4b43833321eaeb544ce324cf8ffcefa6.zip
Add show app info
Diffstat (limited to 'core/src')
-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