4

I have an app that sends files with custom file extensions via email that are essentially just encrypted xml files. My app has an intent filter to open these, and it works on my particular phone (Samsung Galazy S Mesmerize), but when I try to open an attachment with my custom file extension on some other phones (Electrify, Thunderbolt, etc) it says there isn't anything that can open that file. (BTW the phones that are trying DO have my app installed).

Here is my intent-filter:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:scheme="file" />
  <data android:mimeType="*/*" />
  <data android:pathPattern=".*\\.tgtp" />   
  <data android:host="*" />
</intent-filter>

Is there anything I can do to ensure that all android phones will be able to open my custom file extension when they have my app installed?

Thanks

Nick
  • 1,262
  • 1
  • 17
  • 32
  • To be completely honest i thought that wasnt possible, unless you have chosen an existing mimetype. But it has been awhile since i looked at it. Maybe its the version of android that differs on the phones? – Anders Metnik May 01 '12 at 14:12
  • Can anyone verify that it isn't possible? If that's the case thats fine, and I will plan accordingly. If it is possible, I'd really like to know what's up. And the phones I've tested on are definitely different android versions (2.3 / 4.0). I can't imagine how/why that would change anything though – Nick May 01 '12 at 14:15
  • Does anything appear in the log when you try this? – Ron May 12 '12 at 06:02
  • have you tried this - http://stackoverflow.com/questions/4799576/register-new-file-type-in-android – Ron May 12 '12 at 06:06

2 Answers2

5

I guess it depends on the path the files are located at on your other devices. I found that the pathPattern attribute in the intent filter is very sensitive to the full path of the file.

Take a look at the following answer for a similar question: https://stackoverflow.com/a/7102838/624109

Basically, you need to have several pathPattern attributes that will most likely capture the location of your file.

Another thing is that I think that even if you use local files, you still need to have the port attribute.

These two changes are what made it work for me after hours of digging around.

Community
  • 1
  • 1
Muzikant
  • 8,070
  • 5
  • 54
  • 88
  • That did the trick! I guess since the original file is xml based the text/xml scheme makes sense. Thanks! – Nick May 14 '12 at 20:56
  • @Nick: do still understand your comment yourself? What did the trick? the port attribute? The scheme or the type? – Robert Siemer May 09 '13 at 17:19
0

Even though the developer documentation says it would be the same, I believe it’s not:

Try to put all <data ...> attributes in the same element, i.e. have only one <data>.

Have more then one <data> only to widen the filter with other URIs or MIME types...

Robert Siemer
  • 32,405
  • 11
  • 84
  • 94