From 1bc48a6b4b43833321eaeb544ce324cf8ffcefa6 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 13 Nov 2017 04:51:43 -0500 Subject: Add show app info --- .../main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 -- cgit v1.2.3