Both these are used by different apps. Facebook shared with File Uris and Whatsapp with Content Uris. If my app can share Videos and pictures, which one should I use?
Also, if my app should accept videos and pictures, for which type should I be prepared? And if for both, should I convert the Content URI into a File Uri or the other way around?
If my app can share Videos and pictures, which one should I use?
On Android 7.0+, you have little choice but to share using a content Uri, such as from FileProvider.
On Android 6.0 and older, if the content is on internal storage, you also have to use FileProvider, as third-party apps have no access to your portion of internal storage. If the content is on external storage, you could use either file or content. The older the device, the more likely it is that pre-installed apps will only support file.
if my app should accept videos and pictures, for which type should I be prepared?
Ideally, both. If by "accept" you mean via ACTION_SEND, you have no choice but to support both. For ACTION_VIEW and Intent actions like it, where the data facet of an Intent is used for the Uri, use the <data> element to advertise which scheme(s) you support.
should I convert the Content URI into a File Uri or the other way around?
Neither. You consume the content from its original source. A ContentProvider supports both schemes, for things like getType() and openInputStream().
Related
I have a chat app where users share images/video/audio etc. I need organized my directory structure, where i need to keep sent files in separate sub-folder and hide it from gallery apps but user can able to locate with file manager apps.
The only things comes in my mind that create .nomedia file in sent folders but in android 11+ we can't create files just like that. Our users gallery apps messed up with sent and receive images, I am not able to find any solution on StackOverFlow and on other documentations or google search.
On Android 11+ i am using MediaStore to read and write media files. Anyone have any idea how can i create .nomedia files in External Storage like Pictures/Movies/Documents etc.
I am creating .nomedia below andoird 10 like this but i have no idea how to create in android 11+
File file = new File(dir+".nomedia");
file.createNewFile();
I am maintaining a legacy Java / C++ application for Android which is backwards compatible to some API 18. It contains a rudimentary e-mail client.
Users receive e-mails with various attachments (HTML, PDF, JPG, MP3, MP4, XLS) and want to be able to open them in external applications. Prior to Android Q, I just saved the attachments to disk and invoked an intent with ACTION_VIEW on the file:///uri to the saved attachment.
This stopped working in Android Q with the new restrictions on storage access. Even if I save a HTML file to, say, Download/ directory, Chrome won't open it from an ACTION_VIEW intent: the error is ERR_ACCESS_DENIED.
I don't know how to fix this problem with the new scoped storage. Is there even a unified way how to open file types as different as PDF, HTML, JPG, MP3, MP4, XLS in external applications using intents? Or do I have to branch my code according to the type of the media and use some different approaches and directories for images, sounds, video and documents?
Is ACTION_VIEW still universally capable of opening files such as HTML, or has it been restricted to media files only? I would be happy to have an universal way of opening all temporarily saved attachments (smaller code to maintain is always better), but I am not sure if it is possible at all anymore.
Any help is appreciated.
I got a web application with a Java backend and React frontend. It allows users to upload and display pictures like in an album setting.
The application fetches data from a MS SQL server containing data about an image and then displays it in react.
The database contains a table with information about the image (filename, extension etc.) but not a BLOB.
I am currently displaying the image in react by creating an url from my local machine.
My question is now, what file system alternatives is there when i want to stop storing the images locally on my windows machine. Is it possible to use Google Drive API or something similar? What about SFTP? Would appreciate free solutions to begin with.
You can use Amazon S3 to store your images. store information about the image like file name, bucket name ,... etc in your database and store the image itself in Amazon S3.
There are also other alternatives to Amazon S3 if you want, like MinIO, which is open source and S3 compatible.
I have a multiple ts files and would like to upload it to YouTube as one video. This basically breaks the question into two parts and would like to know if it's possible.
Can multiple individual files be uploaded in a sequence as one video to YouTube through their API?
Does YouTube truly supports ts files upload?
1. Can multiple individual files be uploaded in a sequence as one video to YouTube through their API?
YouTube is a video upload platform and does not provide any functionality for video editing. Hence, if you'd like to upload these files as one video, you'd have to join these yourself and then upload. However, you could upload these videos as a playlist in your channel. For which, take a look at the playlist and Insert video section of the YouTube API documentation.
2. Does YouTube truly supports ts files upload?
Here is a list of supported Youtube file formats. Unfortunately, it doesn't seem like TS is one of them.
Hope this helps.
I have to associate a couple of text parameters (a UUID and a couple of strings representing integers) to a PNG image in a way they can follow the image when the PNG file is passed from an Android device to another through the Net. This is the typical situation in which I would use a couple of custom auxiliary chuncks (similar to EXIF fields ) to store my data inside the PNG image itself.
Maybe it is just me but the only info I was able to find about reading and writing PNG custom metadata from Java code on Android was this SO post:
Writing image metadata in Java, preferably PNG
that even offers some code (quite verbose, as usual with Java).
Those same SO post refers also to PNGJ: http://code.google.com/p/pngj/
To be honest, I would be happy to not use yet another library in this project.
Does anybody know of others ways to write and read text metadata in a PNG file in Android? Maybe a less verbose way... Maybe a way that does not require a separated library....
Any other source of information? Any tutorial? Any example?
I'm open to use a different (but equivalent) image file format, if needed (JPEG, whatever).
A solution working also on iOS and Windows 8 Phone would be a plus but it is not actually required.
I had to do something similar lately, so I had to study the subject.
Android offers you no option of manipulating png metadata. You will have to use an external library (PNGJ seems like a good option).
In my case, since I am making changes to the Android frameworks, I didn't use an external lib, but made changes to skia (the Android graphics library instead).
If you need more info on that I can give you, but I think it's irrelevant in your case.