开发者

Download ics file in android?

I use <data android:mimeType="text/calendar" /> in my manifest file it doesn't supports to open ics file in Android default email application.Is there any other way to open ics file? I use <data android:mimeType="*/*"> But it supports to open all file format.I need to restrict my application to open ics file only.I am new to a开发者_如何学运维ndroid.Can anyone help me to solve this????


Use android:pathPattern. It supports path patterns like *.ics

The documentations says:

The pathPattern attribute specifies a complete path that is matched against the complete path in the > Intent object, but it can contain the following wildcards:

  • An asterisk ('*') matches a sequence of 0 to many occurrences of the immediately preceding character.
  • A period followed by an asterisk (".*") matches any sequence of 0 to many characters.


As Ankit stated use the data android:pathPattern but also have one that has the mimetype as well.

The mimetype depends on the server sending the correct content type for the file. if they don't send the correct mimetype then you can fallback on the pathPattern, but this may miss some items too, if the server is sending the ics from a dynamic page.

A MIME media type, such as image/jpeg or audio/mpeg4-generic. The subtype can be the asterisk wildcard (*) to indicate that any subtype matches.

Which means, you should not be able to use */*, but you wouldn't want to use that nor would you really want to use text/* either as those are to general and would cause the activity selection menu for lots of different files.

you may also want to use the android:scheme and set it to "webcal", that may help trap some of the links as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜