Issue
Is it possible to add extras to an intent which has ACTION_CREATE_DOCUMENT as action?
Here is how I create my Intent:
// Request code for creating a PDF document.
const val CREATE_FILE = 1
private fun createFile(pickerInitialUri: Uri) {
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "application/pdf"
putExtra(Intent.EXTRA_TITLE, "invoice.pdf")
// Set extra here
putExtra("url", url)
// Optionally, specify a URI for the directory that should be opened in
// the system file picker before your app creates the document.
putExtra(DocumentsContract.EXTRA_INITIAL_URI, pickerInitialUri)
}
startActivityForResult(intent, CREATE_FILE)
}
And I obtain the extras in the onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)
method.
I obtain my extras like this:
val extra = data?.getStringExtra("url")
But extras are always null
Solution
And I obtain the extras in the onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) method.
That works for approximately zero Intent
actions and apps responding to them. It will not work for ACTION_CREATE_DOCUMENT
.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.