How can I setup an android intent for multiple types of files (pdf, office, images, text) and return a path?
You can use Intent.ACTION_OPEN_DOCUMENT
,
Each document is represented as a content:// URI backed by a DocumentsProvider, which can be opened as a stream with openFileDescriptor(Uri, String), or queried for DocumentsContract.Document metadata.
All selected documents are returned to the calling application with persistable read and write permission grants. If you want to maintain access to the documents across device reboots, you need to explicitly take the persistable permissions using takePersistableUriPermission(Uri, int).
Callers must indicate the acceptable document MIME types through setType(String). For example, to select photos, use image/*. If multiple disjoint MIME types are acceptable, define them in EXTRA_MIME_TYPES and setType(String) to */*
.
For the more details, please refer here.
How can i ask for multpile MIME types with ActivityResultLauncher.GetContent()?
is there any way to ask for multiple MIME types when using registerForActivityResult ?
Not directly with the current version of ActivityResultContracts.GetContent
. However, you should be able to subclass it, override createIntent()
, and from there customize the generated Intent
. You can then try adding EXTRA_MIME_TYPES
to that Intent
with a String[]
of the additional MIME types that you want.
How to add multiple Mime types for volley MultipartEntityBuilder
use mime type "*/*"
it will accept all types of files
var fileBody = ProgressRequestBody(fileToUpload, "*/*", this)
photos = MultipartBody.Part.createFormData(key, fileToUpload.name, fileBody)
Like in retrofit I make RequestBody object as above and it accepts any type of file
Related Topics
How to Test If a Fragment View Is Visible to the User
How to Send a Simple Email Programmatically? (Exists a Simple Way to Do It)
Gridview with Different Cells Sizes, Pinterest Style
Equivalent of Clean & Build in Android Studio
Read Command Output Inside Su Process
Set Permission for Getting User's Email Id from Facebook Login
Project Has No Default.Properties File! Edit the Project Properties to Set One
How to Handle Asynctask's in Actionbaractivity Fragments When Viewpager Is Used
Android APK File: Re-Activate Older APK File in Google Play Store
What Are the Android Sdk Build-Tools, Platform-Tools and Tools? and Which Version Should Be Used
How to Remove the Top and Bottom Space on Textview of Android
Android Wifi How to Detect When Specific Wifi Connection Is Available
Disable Soft-Keyboard from Edittext But Still Allow Copy/Paste
How to Set Spinner Default Value to Null
Android: How to Monitor Wifi Signal Strength
Fragment Replacing in Recyclerview Item