Creating app which opens a custom file extension
Solution 1
I think you need to do that type of customization via intent-filter
something like:
<intent-filter android:icon="your_drawable-resource"
android:label="your_string_resource"
android:priority="integer">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.YOUR_CUSTOM_FILE_EXTENSION" />
</intent-filter>
Also you should look:
- Custom Filetype in Android not working
- Android intent filter for a particular file extension?
- android intent filter for custom file extension
Solution 2
One possible answer is shown here . Try some customisation for intent filters.
<intent-filter android:priority="999">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />
<data android:host="*" />
<data android:mimeType="application/octet-stream" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.yourextension" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.yourextension" />
<data android:pathPattern=".*\\..*\\..*\\.yourextension" />
<data android:pathPattern=".*\\..*\\.yourextension" />
<data android:pathPattern=".*\\.yourextension" />
<data android:scheme="content" />
</intent-filter>
Related videos on Youtube
topher
Updated on September 15, 2022Comments
-
topher over 1 year
Want to create an android application, which opens a custom-build file extension (for example, I want to open .abcd files)
It is something like Adobe Reader that opens .pdf files, or Photo Viewer that opens .jpg files
Specific conditions:
1. The .abcd file should be outside / external from the application itself. (as .pdf is to Adobe Reader)
2. The .abcd file would be a zipped file, which contains few folders and .xml, .txt, and .jpg files. I think I want to extract it - maybe temporarily - to somewhere in the storage (definitely need a zipper/unzipper library), then read the individual .xml, .txt, and .jpg files.Looking for insights and answers for this problem.
Additional information:
I am relatively new to Android programming.-
Emmanuel Touzery over 10 yearsTo get your application to be invoked when someone taps on a .abcd file in the file explorer: stackoverflow.com/questions/3760276/… Once you are called, you can parse the file yourself. Java offers facilities to unzip files: java.util.ZipFile.
-
topher over 10 years@EmmanuelTouzery +1, thank you very much. If doing so, will the file be passed into an argument to the application ?
-
Emmanuel Touzery over 10 yearsIt doesn't work like that, there is no main on android -- you'll receive an Intent and you can then handle it. Check out: developer.android.com/guide/components/intents-filters.html
-
topher over 10 yearsOh I see, thank you again. :)
-
Rishabh Srivastava over 10 yearsdid you get a solution?
-
topher over 10 years@RishabhSrivastava I'm still working on this project. I've found a way to unzip files from external storage (I forgot the link, but can be found with a simple google search).
-