GetFilesDir() and getExternalFilesDir() and getExternalFilesDirs() are still available but files stored on those directories are deleted when my app is uninstalled. Besides still this is not what Google Chrome does. But this is just a patch for developers in order to gain time until they make changes and adapt their code. NULLĪdding requestLegacyExternalStorage="false" as an attribute of Application label of my AndroidManifest.xml. I've also tried to get _CONTENT_URI or _CONTENT_URI and save a file by using (), but what a coincidence although they are annotated as they in fact return. But this does not create a directory but a file. Or again by using ACTION_CREATE_DOCUMENT, save the Uri that I get in onActivityResult() and use grantPermission() and getContentResolver().takePersistableUriPermission(). What an ugly activity to ask user for permission, isn't it? Even though this is NOT what Google Chrome does. I = sm.getPrimaryStorageVolume().createOpenDocumentTreeIntent() Get grant access using SAF at the beginning of the app with an uri pointing to any directory for download contents: StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE) But am I supposed to open this Intent on every file? My app can download chat files automatically being on background. An Activity is always opened to ask user where to place the file. Open SAF with an ACTION_CREATE_DOCUMENT Intent to ask for permission but apparently there's no way to open it silently. ![]() I have read android for developers documentation, lots of questions on Stackoverflow, blog posts over the Internet and Google Groups but still I haven't found a way to keep doing exactly the same as in Android 9 nor even a solution that plenty satisfies me. I have been googling for some days already how apps can download a file directly to Download directory on Android 10 (Q) without having to ask user where to place it, the same way Chrome does. But then I analyzed Chrome and it targets Android 10 without using requestLegacyExternalStorage. ![]() I first analyzed Whatsapp to see how they achieve it but they make use of requestLegacyExternalStorage attribute on AndroidManifest. Impossible? but then why Google Chrome or other browsers are able to do that? They in fact still download files to Download directory without asking user in Android 10. In Android 9 or lower I directly download those files to Download directory, but that's now impossible in Android 10 without showing an Intent to the user to ask where to download them. Lets say I'm developing a chat app that is able to share with others ANY kind of files (no mimetype restriction): like images, videos, documents, but also compressed files like zip, rar, apk or even less frequent types of files like photoshop or autocad files, for example.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |