在intent-filter中,我们一般都会使用到android.intent.action.MAIN和android.intent.category.LAUNCHER这两个属性值,我们先来简单说说它们的作用。
android.intent.action.MAIN:决定应用程序最先启动的Activity 。
android.intent.category.LAUNCHER:决定应用程序是否显示在程序列表里。
如果我们希望隐藏icon,实际上就是注释掉intent-filter中的一句,把它的android.intent.category.LAUNCHER这个属性去掉。
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<!--
<category android:name="android.intent.category.LAUNCHER" />
-->
一个intent filter是一个IntentFilter类的实例。但是,android系统必须在组件未启动的情况下就知道它的能力,因此intent filter一般不会在java代码中设置,而是在应用的manifest文件中作为<intent-filter>
元素的方式声明。一个例外是,为broadcast receiver注册动态的filter,可以调用Context.registerReceiver()方法,通过直接实例化IntentFilter 对象创建。
filter有三个平等的部分:action、data和category。隐式intent将测试这三个部分。一个intent要想投递到一个组 件,那么这三个测试都要通过才行。当然如果组件有多个intent filter,可能一个intent没有通过,但是通过了另外的一个,这样也可以把intent投递到组件。
action测试
<intent-filter . . . >
<action android:name="com.example.project.SHOW_CURRENT" />
<action android:name="com.example.project.SHOW_RECENT" />
<action android:name="com.example.project.SHOW_PENDING" />
. . .
</intent-filter>
要想通过测试,intent中的action名称要匹配其中之一。
如果intent filter中不包含action列表,而intent指定action,那么intent没有匹配的action,不通过;intent未指定action,而intent filter指定,会自动通过测试。
下面我们来看看action具有哪些属性值,具体的在Intent这个类里面进行了定义:
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Standard intent activity actions (see action variable).
//作为主入口点启动,不需要接收数据。
public static final String ACTION_MAIN = "android.intent.action.MAIN";
//向用户显示数据,比较通用,会根据用户的数据类型打开相应的Activity。
//比如 tel:13400010001打开拨号程序,http://www.g.cn则会打开浏览器等。
public static final String ACTION_VIEW = "android.intent.action.VIEW";
//默认动作
public static final String ACTION_DEFAULT = ACTION_VIEW;
// 用于指定一些数据应该附属于一些其他的地方,例如,图片数据应该附属于联系人
public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
public static final String ACTION_EDIT = "android.intent.action.EDIT";
public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
public static final String ACTION_PICK = "android.intent.action.PICK";
public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
//显示一个activity选择器,允许用户在进程之前选择他们想要的,与之对应的是Intent.ACTION_GET_CONTENT
public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
// 允许用户选择特殊种类的数据,并返回(特殊种类的数据:照一张相片或录一段音)
public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
//调用拨号面板
public static final String ACTION_DIAL = "android.intent.action.DIAL";
// 呼叫指定的电话号码
public static final String ACTION_CALL = "android.intent.action.CALL";
public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
//发送短信息
public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
public static final String ACTION_SEND = "android.intent.action.SEND";
public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
public static final String ACTION_INSERT = "android.intent.action.INSERT";
public static final String ACTION_PASTE = "android.intent.action.PASTE";
public static final String ACTION_DELETE = "android.intent.action.DELETE";
public static final String ACTION_RUN = "android.intent.action.RUN";
public static final String ACTION_SYNC = "android.intent.action.SYNC";
public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
// 列举所有可用的应用
public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
public static final String ACTION_MANAGE_NETWORK_USAGE = "android.intent.action.MANAGE_NETWORK_USAGE";
public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Standard intent broadcast actions (see action variable).
public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
public static final String ACTION_SYNC_STATE_CHANGED = "android.intent.action.SYNC_STATE_CHANGED";
public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
public static final String ACTION_PACKAGE_FULLY_REMOVED = "android.intent.action.PACKAGE_FULLY_REMOVED";
public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
public static final String ACTION_POWER_DISCONNECTED = "android.intent.action.ACTION_POWER_DISCONNECTED";
public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
public static final String ACTION_GTALK_SERVICE_CONNECTED = "android.intent.action.GTALK_CONNECTED";
public static final String ACTION_GTALK_SERVICE_DISCONNECTED = "android.intent.action.GTALK_DISCONNECTED";
public static final String ACTION_INPUT_METHOD_CHANGED = "android.intent.action.INPUT_METHOD_CHANGED";
public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
public static final String ACTION_PROVIDER_CHANGED = "android.intent.action.PROVIDER_CHANGED";
public static final String ACTION_HEADSET_PLUG = "android.intent.action.HEADSET_PLUG";
public static final String ACTION_ANALOG_AUDIO_DOCK_PLUG = "android.intent.action.ANALOG_AUDIO_DOCK_PLUG";
public static final String ACTION_DIGITAL_AUDIO_DOCK_PLUG = "android.intent.action.DIGITAL_AUDIO_DOCK_PLUG";
public static final String ACTION_HDMI_AUDIO_PLUG = "android.intent.action.HDMI_AUDIO_PLUG";
public static final String ACTION_USB_AUDIO_ACCESSORY_PLUG = "android.intent.action.USB_AUDIO_ACCESSORY_PLUG";
public static final String ACTION_USB_AUDIO_DEVICE_PLUG = "android.intent.action.USB_AUDIO_DEVICE_PLUG";
public static final String ACTION_ADVANCED_SETTINGS_CHANGED = "android.intent.action.ADVANCED_SETTINGS";
public static final String ACTION_NEW_OUTGOING_CALL = "android.intent.action.NEW_OUTGOING_CALL";
public static final String ACTION_REBOOT = "android.intent.action.REBOOT";
public static final String ACTION_DOCK_EVENT = "android.intent.action.DOCK_EVENT";
public static final String ACTION_IDLE_MAINTENANCE_START = "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
public static final String ACTION_IDLE_MAINTENANCE_END = "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
public static final String ACTION_REMOTE_INTENT = "com.google.android.c2dm.intent.RECEIVE";
public static final String ACTION_PRE_BOOT_COMPLETED = "android.intent.action.PRE_BOOT_COMPLETED";
public static final String ACTION_GET_RESTRICTION_ENTRIES = "android.intent.action.GET_RESTRICTION_ENTRIES";
public static final String ACTION_RESTRICTIONS_CHALLENGE = "android.intent.action.RESTRICTIONS_CHALLENGE";
public static final String ACTION_USER_INITIALIZE = "android.intent.action.USER_INITIALIZE";
public static final String ACTION_USER_FOREGROUND = "android.intent.action.USER_FOREGROUND";
public static final String ACTION_USER_BACKGROUND = "android.intent.action.USER_BACKGROUND";
public static final String ACTION_USER_ADDED = "android.intent.action.USER_ADDED";
public static final String ACTION_USER_STARTED = "android.intent.action.USER_STARTED";
public static final String ACTION_USER_STARTING = "android.intent.action.USER_STARTING";
public static final String ACTION_USER_STOPPING = "android.intent.action.USER_STOPPING";
public static final String ACTION_USER_STOPPED = "android.intent.action.USER_STOPPED";
public static final String ACTION_USER_REMOVED = "android.intent.action.USER_REMOVED";
public static final String ACTION_USER_SWITCHED = "android.intent.action.USER_SWITCHED";
public static final String ACTION_USER_INFO_CHANGED = "android.intent.action.USER_INFO_CHANGED";
public static final String ACTION_QUICK_CLOCK = "android.intent.action.QUICK_CLOCK";
public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
category测试
在intent filter中可包含category列表:
<intent-filter . . . >
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
. . .
</intent-filter>
intent想通过测试,必须匹配一个intent filter中的category。
原理上讲,intent如果没有category设置,那么总是可以通过测试。这基本上是正确的,但是有一个例外。Android在为所有隐式 intent执行startActivity()方法的时候,会认为它们至少包含了一个 android.intent.category.DEFAULT。因此,如果activity想收到隐式intent,必须加入这个category。
我们同样看看Intent这里类,就可以知道具有有哪些category属性值了:
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Standard intent categories (see addCategory()).
public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
public static final String CATEGORY_TAB = "android.intent.category.TAB";
public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
public static final String CATEGORY_INFO = "android.intent.category.INFO";
public static final String CATEGORY_HOME = "android.intent.category.HOME";
public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
public static final String CATEGORY_TEST = "android.intent.category.TEST";
public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
data测试
data元素在intent filter元素中,可以重复多次(action和category不允许重复的),也可以根本没有。比如:
<intent-filter . . . >
<data android:mimeType="video/mpeg" android:scheme="http" . . . />
<data android:mimeType="audio/mpeg" android:scheme="http" . . . />
. . .
</intent-filter>
在data元素中指定uri和数据类型(MIME类型)。uri是被分开表示的:
scheme://host:port/path
其中host和port是关联的,如果host没有设置,port也会忽略。
所有这些属性都是可选的,但是不是独立的。比如,如果要设置path,那么也必须设置schema、host和port。
在比较intent中的uri和intent filter中指定的uri时,只会比较intent filter中提及的URL部分。比如,intent filter中只提及了schema,那么所有url包含这个schema的都匹配。在filter的path部分可以使用通配符做到灵活的匹配。
mimeType属性,比uri方式更常用。intent和intent filter都可以使用mime通配符的方式,比如,text/*。
如果既有mimeType,又有uri的情况,比较规则如下:
1、如果intent和intent filter都没有设置任何uri和mimetype,通过;
2、intent包含uri但是没有data type的情况,intent filter的uri部分与之匹配,而且也没有data type部分,可以通过,比如mailto:和tel:
3、intent对象包含数据类型但是没有uri部分,那么仅当intent filter也只有数据类型,而没有uri部分的时候能通过;
4、intent对象包括uri和数据类型(或者数据类型在uri中),分两部分测试,intent对象的数据类型要匹配intent filter,intent对象的uri,或者匹配intent filter中的uri,或者intent filter中没有uri部分(仅当intent对象的uri是content:或者file:的时候)。
关于mimeType到底有哪些,我们可以看看MimeTypeMap和MimeUtils这两个类,在MimeUtils里面我们就可以看到所有的类型了:
static {
add("application/andrew-inset", "ez");
add("application/dsptype", "tsp");
add("application/futuresplash", "spl");
add("application/hta", "hta");
add("application/mac-binhex40", "hqx");
add("application/mac-compactpro", "cpt");
add("application/mathematica", "nb");
add("application/msaccess", "mdb");
add("application/oda", "oda");
add("application/ogg", "ogg");
add("application/pdf", "pdf");
add("application/pgp-keys", "key");
add("application/pgp-signature", "pgp");
add("application/pics-rules", "prf");
add("application/pkix-cert", "cer");
add("application/rar", "rar");
add("application/rdf+xml", "rdf");
add("application/rss+xml", "rss");
add("application/zip", "zip");
add("application/vnd.android.package-archive", "apk");
add("application/vnd.cinderella", "cdy");
add("application/vnd.ms-pki.stl", "stl");
add("application/vnd.oasis.opendocument.database", "odb");
add("application/vnd.oasis.opendocument.formula", "odf");
add("application/vnd.oasis.opendocument.graphics", "odg");
add("application/vnd.oasis.opendocument.graphics-template", "otg");
add("application/vnd.oasis.opendocument.image", "odi");
add("application/vnd.oasis.opendocument.spreadsheet", "ods");
add("application/vnd.oasis.opendocument.spreadsheet-template", "ots");
add("application/vnd.oasis.opendocument.text", "odt");
add("application/vnd.oasis.opendocument.text-master", "odm");
add("application/vnd.oasis.opendocument.text-template", "ott");
add("application/vnd.oasis.opendocument.text-web", "oth");
add("application/vnd.google-earth.kml+xml", "kml");
add("application/vnd.google-earth.kmz", "kmz");
add("application/msword", "doc");
add("application/msword", "dot");
add("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "docx");
add("application/vnd.openxmlformats-officedocument.wordprocessingml.template", "dotx");
add("application/vnd.ms-excel", "xls");
add("application/vnd.ms-excel", "xlt");
add("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx");
add("application/vnd.openxmlformats-officedocument.spreadsheetml.template", "xltx");
add("application/vnd.ms-powerpoint", "ppt");
add("application/vnd.ms-powerpoint", "pot");
add("application/vnd.ms-powerpoint", "pps");
add("application/vnd.openxmlformats-officedocument.presentationml.presentation", "pptx");
add("application/vnd.openxmlformats-officedocument.presentationml.template", "potx");
add("application/vnd.openxmlformats-officedocument.presentationml.slideshow", "ppsx");
add("application/vnd.rim.cod", "cod");
add("application/vnd.smaf", "mmf");
add("application/vnd.stardivision.calc", "sdc");
add("application/vnd.stardivision.draw", "sda");
add("application/vnd.stardivision.impress", "sdd");
add("application/vnd.stardivision.impress", "sdp");
add("application/vnd.stardivision.math", "smf");
add("application/vnd.stardivision.writer", "sdw");
add("application/vnd.stardivision.writer", "vor");
add("application/vnd.stardivision.writer-global", "sgl");
add("application/vnd.sun.xml.calc", "sxc");
add("application/vnd.sun.xml.calc.template", "stc");
add("application/vnd.sun.xml.draw", "sxd");
add("application/vnd.sun.xml.draw.template", "std");
add("application/vnd.sun.xml.impress", "sxi");
add("application/vnd.sun.xml.impress.template", "sti");
add("application/vnd.sun.xml.math", "sxm");
add("application/vnd.sun.xml.writer", "sxw");
add("application/vnd.sun.xml.writer.global", "sxg");
add("application/vnd.sun.xml.writer.template", "stw");
add("application/vnd.visio", "vsd");
add("application/x-abiword", "abw");
add("application/x-apple-diskimage", "dmg");
add("application/x-bcpio", "bcpio");
add("application/x-bittorrent", "torrent");
add("application/x-cdf", "cdf");
add("application/x-cdlink", "vcd");
add("application/x-chess-pgn", "pgn");
add("application/x-cpio", "cpio");
add("application/x-debian-package", "deb");
add("application/x-debian-package", "udeb");
add("application/x-director", "dcr");
add("application/x-director", "dir");
add("application/x-director", "dxr");
add("application/x-dms", "dms");
add("application/x-doom", "wad");
add("application/x-dvi", "dvi");
add("application/x-flac", "flac");
add("application/x-font", "pfa");
add("application/x-font", "pfb");
add("application/x-font", "gsf");
add("application/x-font", "pcf");
add("application/x-font", "pcf.Z");
add("application/x-freemind", "mm");
add("application/x-futuresplash", "spl");
add("application/x-gnumeric", "gnumeric");
add("application/x-go-sgf", "sgf");
add("application/x-graphing-calculator", "gcf");
add("application/x-gtar", "tgz");
add("application/x-gtar", "gtar");
add("application/x-gtar", "taz");
add("application/x-hdf", "hdf");
add("application/x-ica", "ica");
add("application/x-internet-signup", "ins");
add("application/x-internet-signup", "isp");
add("application/x-iphone", "iii");
add("application/x-iso9660-image", "iso");
add("application/x-jmol", "jmz");
add("application/x-kchart", "chrt");
add("application/x-killustrator", "kil");
add("application/x-koan", "skp");
add("application/x-koan", "skd");
add("application/x-koan", "skt");
add("application/x-koan", "skm");
add("application/x-kpresenter", "kpr");
add("application/x-kpresenter", "kpt");
add("application/x-kspread", "ksp");
add("application/x-kword", "kwd");
add("application/x-kword", "kwt");
add("application/x-latex", "latex");
add("application/x-lha", "lha");
add("application/x-lzh", "lzh");
add("application/x-lzx", "lzx");
add("application/x-maker", "frm");
add("application/x-maker", "maker");
add("application/x-maker", "frame");
add("application/x-maker", "fb");
add("application/x-maker", "book");
add("application/x-maker", "fbdoc");
add("application/x-mif", "mif");
add("application/x-ms-wmd", "wmd");
add("application/x-ms-wmz", "wmz");
add("application/x-msi", "msi");
add("application/x-ns-proxy-autoconfig", "pac");
add("application/x-nwc", "nwc");
add("application/x-object", "o");
add("application/x-oz-application", "oza");
add("application/x-pem-file", "pem");
add("application/x-pkcs12", "p12");
add("application/x-pkcs12", "pfx");
add("application/x-pkcs7-certreqresp", "p7r");
add("application/x-pkcs7-crl", "crl");
add("application/x-quicktimeplayer", "qtl");
add("application/x-shar", "shar");
add("application/x-shockwave-flash", "swf");
add("application/x-stuffit", "sit");
add("application/x-sv4cpio", "sv4cpio");
add("application/x-sv4crc", "sv4crc");
add("application/x-tar", "tar");
add("application/x-texinfo", "texinfo");
add("application/x-texinfo", "texi");
add("application/x-troff", "t");
add("application/x-troff", "roff");
add("application/x-troff-man", "man");
add("application/x-ustar", "ustar");
add("application/x-wais-source", "src");
add("application/x-wingz", "wz");
add("application/x-webarchive", "webarchive");
add("application/x-webarchive-xml", "webarchivexml");
add("application/x-x509-ca-cert", "crt");
add("application/x-x509-user-cert", "crt");
add("application/x-x509-server-cert", "crt");
add("application/x-xcf", "xcf");
add("application/x-xfig", "fig");
add("application/xhtml+xml", "xhtml");
add("audio/3gpp", "3gpp");
add("audio/amr", "amr");
add("audio/basic", "snd");
add("audio/midi", "mid");
add("audio/midi", "midi");
add("audio/midi", "kar");
add("audio/midi", "xmf");
add("audio/mobile-xmf", "mxmf");
// add ".mp3" first so it will be the default for guessExtensionFromMimeType
add("audio/mpeg", "mp3");
add("audio/mpeg", "mpga");
add("audio/mpeg", "mpega");
add("audio/mpeg", "mp2");
add("audio/mpeg", "m4a");
add("audio/mpegurl", "m3u");
add("audio/prs.sid", "sid");
add("audio/x-aiff", "aif");
add("audio/x-aiff", "aiff");
add("audio/x-aiff", "aifc");
add("audio/x-gsm", "gsm");
add("audio/x-mpegurl", "m3u");
add("audio/x-ms-wma", "wma");
add("audio/x-ms-wax", "wax");
add("audio/x-pn-realaudio", "ra");
add("audio/x-pn-realaudio", "rm");
add("audio/x-pn-realaudio", "ram");
add("audio/x-realaudio", "ra");
add("audio/x-scpls", "pls");
add("audio/x-sd2", "sd2");
add("audio/x-wav", "wav");
add("image/bmp", "bmp");
add("image/gif", "gif");
add("image/ico", "cur");
add("image/ico", "ico");
add("image/ief", "ief");
add("image/jpeg", "jpeg");
add("image/jpeg", "jpg");
add("image/jpeg", "jpe");
add("image/pcx", "pcx");
add("image/png", "png");
add("image/svg+xml", "svg");
add("image/svg+xml", "svgz");
add("image/tiff", "tiff");
add("image/tiff", "tif");
add("image/vnd.djvu", "djvu");
add("image/vnd.djvu", "djv");
add("image/vnd.wap.wbmp", "wbmp");
add("image/x-cmu-raster", "ras");
add("image/x-coreldraw", "cdr");
add("image/x-coreldrawpattern", "pat");
add("image/x-coreldrawtemplate", "cdt");
add("image/x-corelphotopaint", "cpt");
add("image/x-icon", "ico");
add("image/x-jg", "art");
add("image/x-jng", "jng");
add("image/x-ms-bmp", "bmp");
add("image/x-photoshop", "psd");
add("image/x-portable-anymap", "pnm");
add("image/x-portable-bitmap", "pbm");
add("image/x-portable-graymap", "pgm");
add("image/x-portable-pixmap", "ppm");
add("image/x-rgb", "rgb");
add("image/x-xbitmap", "xbm");
add("image/x-xpixmap", "xpm");
add("image/x-xwindowdump", "xwd");
add("model/iges", "igs");
add("model/iges", "iges");
add("model/mesh", "msh");
add("model/mesh", "mesh");
add("model/mesh", "silo");
add("text/calendar", "ics");
add("text/calendar", "icz");
add("text/comma-separated-values", "csv");
add("text/css", "css");
add("text/html", "htm");
add("text/html", "html");
add("text/h323", "323");
add("text/iuls", "uls");
add("text/mathml", "mml");
// add ".txt" first so it will be the default for guessExtensionFromMimeType
add("text/plain", "txt");
add("text/plain", "asc");
add("text/plain", "text");
add("text/plain", "diff");
add("text/plain", "po"); // reserve "pot" for vnd.ms-powerpoint
add("text/richtext", "rtx");
add("text/rtf", "rtf");
add("text/texmacs", "ts");
add("text/text", "phps");
add("text/tab-separated-values", "tsv");
add("text/xml", "xml");
add("text/x-bibtex", "bib");
add("text/x-boo", "boo");
add("text/x-c++hdr", "hpp");
add("text/x-c++hdr", "h++");
add("text/x-c++hdr", "hxx");
add("text/x-c++hdr", "hh");
add("text/x-c++src", "cpp");
add("text/x-c++src", "c++");
add("text/x-c++src", "cc");
add("text/x-c++src", "cxx");
add("text/x-chdr", "h");
add("text/x-component", "htc");
add("text/x-csh", "csh");
add("text/x-csrc", "c");
add("text/x-dsrc", "d");
add("text/x-haskell", "hs");
add("text/x-java", "java");
add("text/x-literate-haskell", "lhs");
add("text/x-moc", "moc");
add("text/x-pascal", "p");
add("text/x-pascal", "pas");
add("text/x-pcs-gcd", "gcd");
add("text/x-setext", "etx");
add("text/x-tcl", "tcl");
add("text/x-tex", "tex");
add("text/x-tex", "ltx");
add("text/x-tex", "sty");
add("text/x-tex", "cls");
add("text/x-vcalendar", "vcs");
add("text/x-vcard", "vcf");
add("video/3gpp", "3gpp");
add("video/3gpp", "3gp");
add("video/3gpp", "3g2");
add("video/dl", "dl");
add("video/dv", "dif");
add("video/dv", "dv");
add("video/fli", "fli");
add("video/m4v", "m4v");
add("video/mpeg", "mpeg");
add("video/mpeg", "mpg");
add("video/mpeg", "mpe");
add("video/mp4", "mp4");
add("video/mpeg", "VOB");
add("video/quicktime", "qt");
add("video/quicktime", "mov");
add("video/vnd.mpegurl", "mxu");
add("video/x-la-asf", "lsf");
add("video/x-la-asf", "lsx");
add("video/x-mng", "mng");
add("video/x-ms-asf", "asf");
add("video/x-ms-asf", "asx");
add("video/x-ms-wm", "wm");
add("video/x-ms-wmv", "wmv");
add("video/x-ms-wmx", "wmx");
add("video/x-ms-wvx", "wvx");
add("video/x-msvideo", "avi");
add("video/x-sgi-movie", "movie");
add("video/x-webex", "wrf");
add("x-conference/x-cooltalk", "ice");
add("x-epoc/x-sisx-app", "sisx");
applyOverrides();
}