Activity配置檔案中的intent-filter
在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();
}
相關文章
- Laravel 中的配置檔案Laravel
- SpringBoot專案中獲取配置檔案的配置資訊Spring Boot
- 【筆記】【Android】Manifest中的intent-filter使用筆記AndroidIntentFilter
- Spring - 配置檔案中的特殊字元Spring字元
- Deployer recipe中Laravel配置檔案Laravel
- java中讀取配置檔案Java
- Golang專案中讀取配置檔案Golang
- .Net Core中的配置檔案原始碼解析原始碼
- struts2中的6大配置檔案
- 請問如何部署jboss中的配置檔案.
- java中讀取.properties配置檔案Java
- apache 配置檔案的配置(轉)Apache
- SpringBoot專案配置檔案中密碼的加密Spring Boot密碼加密
- 統一為專案中的Activity新增Toolbar
- ssm的配置檔案SSM
- 解決kettle配置檔案中的中文亂碼
- WCF中的web.config配置檔案Web
- 解決RHEL5.0中YUM的配置檔案
- C#中讀寫INI配置檔案C#
- Git配置配置檔案Git
- Orace RAC安裝-DNS安裝-配置/var/named/檔案中的2個檔案DNS
- Structs的配置檔案都在一個檔案(struct-config.xml)中嗎?StructXML
- Centos7 中 Systemd 的Unit檔案配置說明CentOS
- redis配置檔案中的保護模式protected-modeRedis模式
- Centos系統中 Systemd 的Unit檔案配置說明CentOS
- xcode配置檔案中,Architectures表示的意義XCode
- Spring - 配置檔案中的classpath: 和 classpath*: 的區別Spring
- 關於配置檔案中的預設值的問題
- ThinkPHP配置檔案的方法PHP
- SSM衍生的配置檔案SSM
- 完善ANT的配置檔案
- 修改Oracle的配置檔案Oracle
- 我的tmux配置檔案UX
- 我的Nginx配置檔案Nginx
- 配置檔案的編寫
- 2、coredump檔案的配置
- CentOS8中systemd配置檔案說明CentOS
- 如何在python中讀取配置檔案Python