In Kotlin:
val uri = Uri.parse("package:${BuildConfig.APPLICATION_ID}")
startActivity(
Intent(
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
uri
)
)
(from this sample project)
You are probably used to an implicit Intent
(Intent(this, SomeActivity::class.java)
). The docs are asking you to use an explicit Intent
, one with an action string and, in this case, a Uri
. The Uri
will have the package
scheme and identify your app by its application ID.
That code snippet will start a system-supplied activity that, in theory, will let the user opt into granting your app the MANAGE_EXTERNAL_STORAGE
permission.
The Android docs are extensive but not exactly the most welcoming for newcomers
You might wish to consider reading a book or taking a course. Any decent book or course will cover the concept of Intent
actions.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…