15

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.

Andy G
  • 18,518
  • 5
  • 42
  • 63
topher
  • 1,049
  • 4
  • 15
  • 32
  • 3
    To get your application to be invoked when someone taps on a .abcd file in the file explorer: http://stackoverflow.com/questions/3760276/android-intent-filter-associate-app-with-file-extension/12915288#12915288 Once you are called, you can parse the file yourself. Java offers facilities to unzip files: java.util.ZipFile. – Emmanuel Touzery Sep 02 '13 at 17:03
  • @EmmanuelTouzery +1, thank you very much. If doing so, will the file be passed into an argument to the application ? – topher Sep 02 '13 at 17:14
  • It doesn't work like that, there is no main on android -- you'll receive an Intent and you can then handle it. Check out: http://developer.android.com/guide/components/intents-filters.html – Emmanuel Touzery Sep 02 '13 at 17:42
  • Oh I see, thank you again. :) – topher Sep 02 '13 at 17:52
  • did you get a solution? – Rishabh Srivastava Sep 13 '13 at 09:25
  • 1
    @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). – topher Sep 16 '13 at 14:43

2 Answers2

10

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:

Community
  • 1
  • 1
ridoy
  • 6,010
  • 2
  • 26
  • 60
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>
Ráfagan
  • 1,724
  • 2
  • 11
  • 18