INNER CODE UNIT · Kotlin

showStorageAccessDialog

romanvht/ByeByeDPI · app/src/main/java/io/github/romanvht/byedpi/activities/FileActivity.kt:246

    private fun showStorageAccessDialog() {
        val dialog = AlertDialog.Builder(this)
            .setMessage(R.string.file_picker_unavailable)
            .setPositiveButton(R.string.grant_access) { _, _ -> requestStorageAccess() }
            .setNegativeButton(android.R.string.cancel) { _, _ -> finish() }
            .create()
        dialog.setOnCancelListener { finish() }
        dialog.show()
    }

    private fun requestStorageAccess() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            externalRequestActive = true
            try {
                storageAccessLauncher.launch(PermissionUtils.storageAccessIntent(this))
            } catch (exception: Exception) {
                Log.e(TAG, "Failed to open app storage access settings", exception)
                try {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…