Android File Association - java

How do I have a new file type launch my app?
For example if I have a new file type 'file.mjl' and I receive this file as an email, I want Android to associate this file type with my app and allow me to open / save it.

You need to add an intent-filter to the activity you want to launch to work with that file. Here is a link to a great example on that subject:
https://developer.android.com/guide/topics/intents/intents-filters.html

Related

Storage on android 11

I want to store images, videos, audio, and all types of documents like (jpg, mp4, gif, txt, pdf, CSV and etc.) in one folder like 'ABC' and store all that in ("ABC") folder.
I have lots of R&D and done from ALL files access(MANAGE_EXTERNAL_STORAGE) permission and working perfectly as I said as above but play store was rejected due to all file access permission.
Play Store Reject Message
Policy: "Access all files" permission
File and directory attributes on your device are considered your personal and sensitive information and are subject to your personal and sensitive information policies and the following requirements:
The access that your app requests should be limited to device storage, which is essential for your app to function. You cannot request access to device storage for third parties for purposes unrelated to essential app features for your users.
Android devices running Android R (Android 11) or later require MANAGE_EXTERNAL_STORAGE permission to manage access in shared storage. Any app that targets R or later and requests a wide range of access to shared storage (“access to all files”) must pass a proper access review before it can be published. Apps that are allowed to use this permission must clearly display a message to the user asking them to enable Access to all files in the Special App Access settings. For more information on this requirement for R, see this help article.
Find out more about the Access All Files permission
Find out Android storage use cases and recommended methods
Please resolve this issue in Google Play Console.
.
Problem: I need to use the Media Store API
The "Access All Files" permission has been requested, but only media files need access for important features of the app. The MediaStore API allows apps to access and interact with media on external storage volumes without the need for "access to all files."
Update your app to use the Media Store API and remove the "Access All Files" (MANAGE_EXTERNAL_STORAGE) permission.
So please help me have anyone idea using Scoped Storage how it works like create a folder on storage like /data/ABC and store all documents as I mentioned like (jpg, mp4, gif, txt, pdf, CSV and etc.)
I want to like please check below steps
Create a folder (not in a folder like pictures, video, audio, document and download as we have on File manager)
Store file and images in "Created Folder"
Store Download File in "Created Folder"
Easily open after download
Update and Delete Image
Please help me through the coding level if you used it because I have lot's of R&D but not get any document so please don't share any document so if you have used please help me because before 29 API levels it's working and on 29 API level I set android:requestLegacyExternalStorage="true" on manifest so I was also worked for me but android 11(30) what we do please give me a proper solution.
Used code like below
final String directoryFolder =
Environment.getExternalStorageDirectory() + "/" + "ABC";
File file = new File(directoryFolder);
if (!file.exists()) {
file.mkdir();
}
getting error like below
com.androidnetworking.error.ANError:
com.androidnetworking.error.ANError: java.io.FileNotFoundException:
/storage/emulated/0/ABC/19429202106171621.pdf: open failed: EPERM
(Operation not permitted)

Unable to configure JSON in android studio

I'm working on a project. There is a website coded in asp.net and database is SQL. and there is a mobile app connect to this site.in app it used JSON and no db codes. I added new tables to this site and I want to configure it from android studio. I'm new to JSON so I can't config the database from android studio. And I want to know what is a .ashx file is? I can't add code snips due to privacy policy in company. Thank you very much!
.ashx file details:
A file with the ASHX file extension is an ASP.NET Web Handler file that often holds references to other web pages used in an ASP.NET web server application.
The functions in the ASHX file are written in the C# programming language, and sometimes the references are so short that an ASHX file may end up just being a single line of code.
Most people only encounter ASHX files by accident when they try to download a file from a website, like a PDF file. This is because the ASHX file references the PDF file to send it to the browser for download but doesn't name it correctly, attaching .ASHX at the end instead of .PDF.
source: https://www.lifewire.com/ashx-file-2619693
And as far as I think for accessing JSON in the android studio you can look into volley.
Volley Documentation: https://developer.android.com/training/volley

Unable to read file using FileProvider

I have multiple apps that take photos and store them on external storage.
I want to upload the photos along with some metadata to a web application running on my companies server.
I am able to write data and file URI to a database using a ContentProvider.
I have written a SyncAdapter to upload the files via HTTP-POST, but I am stuck because in this SyncAdapter I cannot get permission to read the files.
My big question is: Can I use a FileProvider to overcome this issue?
I am NOT storing the files in the ContentProvider using an intent.
I have tried to set permissions on URL, it failed.
I Desperation I tried to export the FileProvider, which was not allowed.
I want to be able to open an input-stream of the file in another app than the one storing the file without having to start the transfer using an Intent.

importing csv file to launch android app

My project has features to export and import csv file into my application
I have successfully completed export csv file into gmail. I can see the attached file in my gmail inbox.
-Now I want to import the file to my app . On click I need to launch my app and in my second activity I need to perform read from the csv file and add the contents to db.
I wish to ask 2 ways of achieving it.
Is it possible to long press the attachment csv file in my gmail inbox and show my app in the launch list. ( like in IOS ).
If its not possible, then i will download the csv file to my storage. Then from the File Manager folder, I want to use long press -> share via feature.
I want to show my app in the share via feature list.
Upon click , it will launch my app and in my second activity I need to add the implementation of reading the csv file contents row by row and adding to DB.
Let me know how to achieve either 1 or 2 options.
I tried settings action send and category default with mimetype text/csv.
But i cannot see my app in the launcher list.
There is your answer:
https://stackoverflow.com/a/5097734/3703819
use pathPattern: ".*\\.csv"

java- obtain full path to file selected by a user for upload

I am trying to create a simple screen where the file selected for upload by the user is assigned to a file variable.
Google Data APIs have a class "MediaFileSource" which uses "File" to store a file.
Given below is code to assign an image file to a MediaFileSource object.
MediaFileSource myMedia = new MediaFileSource(new File("/home/liz/puppies.jpg"), "image/jpeg");
What I want to do is, ask the user to specify an image for upload, and then assign that image(chosen by the user using my web app) to the MediaFileSource variable. I just need the full path to that image (which was chosen by the end user) to assign it to a MediaFileSource variable.
What is the best way to do this? I plan to create the above functionality in a java web application on Google App Engine.
You can't get the full path on the user machine, only the file name.
It's for security reason and its not related to Google App Engine.

Categories