For example, when you open a text file in the document viewer, a list of software that can be opened is displayed;
How can I make my software appear in this list? You can set the androidmanifest. xml file:
<Activity Android: Name = ". easynote" Android: Label = "@ string/app_name" Android: launchmode = "singletask" Android: screenorientation = "portrait">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
<Intent-filter>
<Action Android: Name = "android. Intent. Action. View"> </Action>
<Category Android: Name = "android. Intent. Category. Default"> </Category>
<Data Android: mimetype = "text/plain"> </data>
</Intent-filter>
</Activity>
The first <intent-filter> tag is available in every program. The key is to add the second tag! In this way, your application will appear in the open list by default...
Note that you need to change mimetype to the type you need. The text file is of course text/plain.
There are other common examples:
Text/plain (plain text)
Text/html (HTML document)
Application/XHTML + XML (XHTML document)
Image/GIF (GIF image)
Image/JPEG (JPEG image) [image/pjpeg in PHP]
Image/PNG (PNG Image) [image/X-PNG in PHP]
Video/MPEG (mPEG animation)
Application/octet-stream (any binary data)
Application/pdf (PDF)
Application/MSWord (Microsoft Word file)
Message/rfc822 (RFC 822 format)
Multipart/alternative (HTML form and plain text form of HTML mail, the same content is expressed in different forms)
Application/X-WWW-form-urlencoded (Form submitted using the http post method)
Multipart/form-data (same as above, but mainly used when the form is submitted along with file upload)
For more information about mimetype, visit: http://blog.csdn.net/tt5267621/article/details/7173972
After associating the program, you also need to handle the parameter passing problem! You need to add the following sample code (not tested) in oncreate ):
Intent intent = getintent (); string action = intent. getaction (); If (intent. action_view.equals (Action) {textview TV = (textview) findviewbyid (R. id. tvtext); TV. settext (intent. getdatastring ());}
"Intent. getdatastring ()" returns the path of the clicked file.
Common mimetype tables for Android
1. MIME type description
Multi-purpose Internet Mail Extension(Mime,Multipurpose Internet Mail Extensions) Is an internet standard that extends the email standard to support mail messages in multiple formats such as non-ASCII characters and binary format attachments.
Content-Type. This header field is used to specify the message type. Generally. [Type]/[subtype]
Type has the following format.
Text: indicates the standardized representation of text information. Text messages can be in multiple character sets or formats;
Multipart: connects multiple parts of the message body to form a message. These parts can be different types of data;
Application: used to transmit application data or binary data;
Message: Used to package an e-mail message;
Image: used to transmit static image data;
Audio: used to transmit audio or audio data;
Video: used to transmit dynamic image data. It can be a video data format edited together with audio.
Subtype is used to specify the type details. The set of Content-Type/subtype pairs and related parameters will increase over time. To ensure that these values are developed in an orderly and open state, mime uses Internet Assigned Numbers Authority (IANA) as the central registration mechanism to manage these values. Common subtype values are as follows:
Text/plain (plain text)
Text/html (HTML document)
Application/XHTML + XML (XHTML document)
Image/GIF (GIF image)
Image/JPEG (JPEG image) [image/pjpeg in PHP]
Image/PNG (PNG Image) [image/X-PNG in PHP]
Video/MPEG (mPEG animation)
Application/octet-stream (any binary data)
Application/pdf (PDF)
Application/MSWord (Microsoft Word file)
Message/rfc822 (RFC 822 format)
Multipart/alternative (HTML form and plain text form of HTML mail, the same content is expressed in different forms)
Application/X-WWW-form-urlencoded (Form submitted using the http post method)
Multipart/form-data (same as above, but mainly used when the form is submitted along with file upload)
2. Common Mime Type tables
From: http://www.littledai.com/20110408/112443/791
3GP video/3GPP
AAB application/X-authoware-bin
AAM application/X-authoware-Map
AAS application/X-authoware-seg
AI Application/postscript
AIF audio/X-AIFF
Aifc audio/X-AIFF
AIFF audio/X-AIFF
ALS audio/X-Alpha5
AMC application/X-mPEG
Ani application/octet-stream
APK application/vnd. Android. Package-Archive
ASC text/plain
ASD application/astound
ASF video/X-MS-ASF
Asn application/astound
ASP application/X-ASAP
ASX video/X-MS-ASF
AU audio/basic
AVB application/octet-stream
AVI Video/X-msvideo
AWB audio/AMR-WB
Bcpio application/X-bcpio
Bin application/octet-stream
BLD application/BLD
Bld2 application/bld2
BMP image/BMP
BPK application/octet-stream
Bz2 applications/x-bzip2
Cal image/X-cals
CCN application/X-CNC
CCO application/X-Cocoa
CDF application/X-netcdf
CGI Magnus-Internal/cgi
Chat application/X-chat
Class Application/octet-stream
CLP application/X-msclip
Cmx application/X-cmx
CO application/x-cult3d-object
Cod image/cis-COD
Cpio application/X-cpio
CPT application/MAC-compactpro
CRD application/X-mscardfile
CSH application/X-CSH
CSM chemical/X-csml
Csml chemical/X-csml
CSS text/CSS
Cur application/octet-stream
Dcm x-lml/X-EVM
DCR application/X-Director
Dcx image/X-dcx
DHTML text/html
Dir application/X-Director
DLL application/octet-stream
DMG application/octet-stream
DMS application/octet-stream
Doc application/MSWord
Dot application/X-dot
DVI application/X-DVI
DwF drawing/X-DwF
DWG application/X-AutoCAD
DXF application/X-AutoCAD
DxR application/X-Director
Ebk application/X-expandedbook
EMB chemical/X-embl-DL-nucleus otide
Embl chemical/X-embl-DL-nucleus otide
EPS application/postscript
ERI image/X-Eri
Es audio/echospeech
ESL audio/echospeech
Etc application/X-earthtime
Etx text/X-setext
Evm x-lml/X-EVM
Evy application/X-envoy
EXE application/octet-stream
Fh4 image/X-freehand
Fh5 image/X-freehand
FHC image/X-freehand
Fif image/FIF
FM application/X-maker
Fpx image/X-fpx
FVI video/isivideo
Gau chemical/X-Gaussian-Input
GCA application/X-GCA-compressed
Gdb x-lml/X-GDB
GIF image/GIF
GPS application/X-GPS
Gtar application/X-gtar
GZ application/X-Gzip
HDF application/X-HDF
HDM text/X-hdml
Hdml text/X-hdml
HLP application/WinHlp
Hqx application/mac-binhex40
Htm text/html
HTML text/html
HTS text/html
Ice X-conference/X-cooltalk
ICO application/octet-stream
IEF image/IEF
IFM image/GIF
Ifs image/IFS
IMy audio/melody
INS application/X-net-install
IPS application/X-ipscript
IPX application/X-ipix
It audio/X-mod
Itz audio/X-mod
Ivr I-World/I-Fig
J2k image/j2k
Jad text/vnd. Sun. J2EE. app-Descriptor
Jam application/X-jam
Jar application/Java-Archive
JNLP application/X-Java-JNLP-File
Jpe image/JPEG
JPEG image/JPEG
Jpg image/JPEG
Jpz image/JPEG
JS application/X-Javascript
JWC application/JWC
Kjx application/X-kjx
AKs X-lml/X-aks
Latex application/X-latex
LCC application/fastman
LCL application/X-digitalloca
LCR application/X-digitalloca
Lgh application/lgh
Lha application/octet-stream
Lml X-lml/X-lml
Lmlpack X-lml/X-lmlpack
LSF video/X-MS-ASF
LSX video/X-MS-ASF
Lzh application/X-lzh
M13 application/X-msmediaview
M14 application/X-msmediaview
M15 audio/X-mod
M3U audio/X-mpegurl
M3url audio/X-mpegurl
Ma1 audio/ma1
Ma2 audio/Ma2
Ma3 audio/ma3
MA5 audio/MA5
MAN application/X-troff-man
Map Magnus-Internal/Imagemap
Mbd application/mbedlet
MCT application/X-mascot
MDB application/X-msaccess
Mdz audio/X-mod
Me application/X-troff-me
Mel text/X-vmel
Mi application/X-MIF
Mid audio/MIDI
MIDI audio/MIDI
MIF application/X-MIF
Mil image/X-cals
Mio audio/X-Mio
Mmf application/X-SKT-lbs
MNG video/X-MNG
Mny application/X-msmoney
MoC application/X-mocha
Mocha application/X-mocha
MoD audio/X-mod
MOF application/X-yumekara
Mol chemical/X-MDL-molfile
Mop chemical/X-mopac-Input
MoV video/QuickTime
Movie video/X-SGI-movie
MP2 audio/X-mPEG
MP3 audio/X-mPEG
MP4 video/MP4
Nmapplication/vnd. mpohun. Certificate
MPE video/MPEG
MPEG Video/MPEG
MPG video/MPEG
Mpg4 video/MP4
Mpga audio/MPEG
MPN application/vnd. mophun. Application
MPP application/vnd. MS-Project
MPs application/X-mapserver
MRl text/X-mrml
Mrm application/X-MRM
MS application/X-troff-MS
MTS application/metastream
CTX application/metastream
MTZ application/metastream
Mzv application/metastream
Nar application/zip
Nbmp image/nbmp
NC application/X-netcdf
Ndb x-lml/X-NDB
Ndwn application/ndwn
NIF application/X-NIF
Nmz application/X-scream
Nokia-op-logo image/vnd. Nok-oplogo-color
Npx application/X-netfpx
Nsnd audio/nsnd
NVA application/x-neva1
ODA application/ODA
Oom application/X-atlasmate-plugin
PAC audio/X-Pac
PAE audio/X-EPAC
Pan application/X-pan
PBM image/X-portable-bitmap
PCX image/X-PCX
PDA image/X-PDA
PDB chemical/X-PDB
PDF application/PDF
PFR application/font-tdpfr
PGM image/X-portable-graymap
PICT image/X-PICT
PM application/X-perl
PMD application/X-PMD
PNG Image/PNG
PNM image/X-portable-anymap
PNZ image/PNG
Pot Application/vnd. MS-PowerPoint
PPM image/X-portable-pixmap
PPS Application/vnd. MS-PowerPoint
PPT application/vnd. MS-PowerPoint
Pqf application/X-cprplayer
Pqi application/cprplayer
PRC application/X-PRC
Proxy application/X-NS-proxy-AutoConfig
PS application/postscript
Ptlk application/listenup
Pub application/X-mspublisher
PVX video/X-Pv-PVX
Qcp audio/vnd. qcelp
Qt video/QuickTime
Qti image/X-QuickTime
QTIF image/X-QuickTime
R3t text/vnd. rn-realtext3d
RA audio/X-PN-RealAudio
Ram audio/X-PN-RealAudio
RAR application/X-Rar-compressed
Ras image/X-CMU-raster
RDF application/RDF + XML
RF image/vnd. Rn-realflash
RGB image/X-RGB
RLF application/X-richlink
Rm audio/X-PN-RealAudio
RMF audio/X-RMF
RMM audio/X-PN-RealAudio
Rmvb audio/X-PN-RealAudio
Rnx application/vnd. Rn-RealPlayer
Roff application/X-troff
RP image/vnd. Rn-realpix
Rpm audio/X-PN-RealAudio-plugin
RT text/vnd. Rn-RealText
Rte x-lml/X-GPS
RTF application/RTF
RTG application/metastream
RTX text/richtext
RV video/vnd. Rn-realvideo
RWC application/X-rogerwilco
S3m audio/X-mod
S3z audio/X-mod
SCA application/X-supercard
SCD application/X-msschedule
SDF application/e-Score
SEA application/X-stuffit
SGM text/X-SGML
SGML text/X-SGML
Sh application/X-SH
Shar application/X-shar
Shtml Magnus-Internal/parsed-html
SHW application/presentations
Si6 image/si6
Si7 image/vnd. stiwap. Sis
Si9 image/vnd. lgtwap. Sis
SIS application/vnd. Symbian. Install
Sit application/X-stuffit
SKD application/X-koan
SKM application/X-koan
SKP application/X-koan
SKT application/X-koan
SLC application/X-Salsa
SMD audio/X-SMD
SMI application/smil
SMIL application/smil
SMP application/studiom
SMZ audio/X-SMD
SND audio/basic
SPC text/X-speech
SPL application/futuresplash
SPR application/X-Sprite
Sprite application/X-Sprite
SPT application/X-SPT
SRC application/X-WAIS-Source
STK application/hyperstudio
STM audio/X-mod
Sv4cpio application/x-sv4cpio
Sv4crc application/x-sv4crc
SVF image/vnd
SVG image/SVG-XML
SVH image/SVH
Svr x-World/X-SVR
SWF application/X-Shockwave-flash
Swfl application/X-Shockwave-flash
T application/X-troff
Tad application/octet-stream
Talk text/X-speech
Tar application/X-Tar
Taz application/X-Tar
TBP application/X-Timbuktu
TBT application/X-Timbuktu
TCL application/X-tcl
Tex application/X-Tex
Texi application/X-texinfo
Texinfo application/X-texinfo
Tgz application/X-Tar
THM application/vnd. Eri. THM
TIF image/tiff
TIFF image/tiff
TKI application/X-tkined
Tkined application/X-tkined
TOC application/TOC
Toy image/toy
Tr application/X-troff
Trk x-lml/X-GPS
TRM application/X-msterminal
Tsi audio/tsplayer
TSP application/dsptype
TSV text/TAB-separated-Values
TSV text/TAB-separated-Values
TTF application/octet-stream
Ttz application/T-time
TXT text/plain
Ult audio/X-mod
USTAR application/X-USTAR
UU application/X-uuencode
UUE application/X-uuencode
VCD application/X-cdlink
VCF text/X-vCard
VDO video/VDO
VIB audio/ViB
Viv video/Vivo
Vivo video/Vivo
VMD application/vocaltec-media-Desc
Vmf application/vocaltec-media-File
VMI application/X-Dreamcast-VMS-Info
VMS application/X-Dreamcast-VMS
Vox audio/voxware
Vqe audio/X-twinvq-plugin
Vqf audio/X-twinvq
Vql audio/X-twinvq
Vre x-World/X-vream
Fig X-World/X-Fig
Vrt x-World/X-VRT
Vrw X-World/X-vream
VTS workbook/formulaone
WAV audio/X-WAV
Wax audio/X-MS-wax
Wbmp image/vnd. WAP. wbmp
Web application/vnd. xara
Wi image/Wavelet
WIS application/X-InstallShield
WM video/X-MS-WM
WMA audio/X-MS-WMA
WMD application/X-MS-WMD
WMF application/X-msmetafile
WML text/vnd. WAP. WML
Wmlc application/vnd. WAP. wmlc
WMLS text/vnd. WAP. WMLScript
Wmlsc application/vnd. WAP. wmlscriptc
WMLScript text/vnd. WAP. WMLScript
WMV audio/X-MS-WMV
Wmx video/X-MS-wmx
WMZ application/X-MS-WMZ
Wpng image/X-Up-wpng
Wpt x-lml/X-GPS
WRI application/X-mswrite
Wrl x-World/X-Fig
Wrz X-World/X-Fig
WS text/vnd. WAP. WMLScript
WSC application/vnd. WAP. wmlscriptc
WV video/Wavelet
WVX video/X-MS-WVX
Wxl application/X-wxl
X-gzip application/X-Gzip
Xar application/vnd. xara
Xbm image/X-xbitmap
Xdm application/X-xdma
Xdma application/X-xdma
Xdw application/vnd.fujixerox.doc uworks
Xht application/XHTML + XML
Xhtm application/XHTML + XML
XHTML application/XHTML + XML
Xla application/vnd. MS-Excel
Xlc application/vnd. MS-Excel
Xll application/X-Excel
XLM application/vnd. MS-Excel
XLS application/vnd. MS-Excel
Xlt application/vnd. MS-Excel
Xlw application/vnd. MS-Excel
XM audio/X-mod
XML text/XML
Xmz audio/X-mod
Xpi application/X-XPInstall
XPM image/X-xpixmap
Xsit text/XML
XSL text/XML
XUL text/XUL
Xwd image/X-xwindowdump
XYZ chemical/X-PDB
Yz1 application/x-yz1
Z application/X-compress
Zac application/X-zaurus-Zac
Zip application/zip