Android 打开应用设置代码,适配9.0

  private fun openSetting() {
        val localIntent = Intent()
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        if (Build.VERSION.SDK_INT >= 9) {
            localIntent.action = "android.settings.APPLICATION_DETAILS_SETTINGS"
            localIntent.data = Uri.fromParts("package", context?.packageName,
                    null)
        } else if (Build.VERSION.SDK_INT <= 8) {
            localIntent.action = Intent.ACTION_VIEW

            localIntent.setClassName("com.android.settings",
                    "com.android.settings.InstalledAppDetails")

            localIntent.putExtra("com.android.settings.ApplicationPkgName",
                    context?.packageName)
        }
        startActivity(localIntent)

    }

你可能感兴趣的:(Android 打开应用设置代码,适配9.0)