首页 > 代码库 > 解决android自带蓝牙不能发送接收某些文件类型

解决android自带蓝牙不能发送接收某些文件类型

        最近,遇到一个蓝牙的bug,刚开始以为不能发送大的文件,最后追踪代码发现,是不能发送某些文件类型的文件的。

        默认之支持所有图片,所有视频,所有音频,文本类型,html,zip,excel,word,ppt,pdf等类型。

        要想让其支持你要发送/接收的文件类型需要在相应地方添加相应的类型。

        发送的文件类型,需要修改package/app/bluetooth目录下的AndroidManifest.xml文件的<data android:mimeType="" />,

添加相应的类型即可。

       接收的文件类型,修改packages/apps/Bluetooth/src/com/android/bluetooth/opp/Constants.java文件中的

ACCEPTABLE_SHARE_INBOUND_TYPES数组即可,在里面添加相应类型。

     

       要支持更多格式文件的传输/接收,请参考如下 MIME 参考手册:

      

下面的参考手册是由 Microsoft Internet Information Server version 5 所支持的 MIMEI 类型列表。

按照内容类型排列的 Mime 类型列表

类型/子类型扩展名
application/envoyevy
application/fractalsfif
application/futuresplashspl
application/htahta
application/internet-property-streamacx
application/mac-binhex40hqx
application/msworddoc
application/msworddot
application/octet-stream*
application/octet-streambin
application/octet-streamclass
application/octet-streamdms
application/octet-streamexe
application/octet-streamlha
application/octet-streamlzh
application/odaoda
application/olescriptaxs
application/pdfpdf
application/pics-rulesprf
application/pkcs10p10
application/pkix-crlcrl
application/postscriptai
application/postscripteps
application/postscriptps
application/rtfrtf
application/set-payment-initiationsetpay
application/set-registration-initiationsetreg
application/vnd.ms-excelxla
application/vnd.ms-excelxlc
application/vnd.ms-excelxlm
application/vnd.ms-excelxls
application/vnd.ms-excelxlt
application/vnd.ms-excelxlw
application/vnd.ms-outlookmsg
application/vnd.ms-pkicertstoresst
application/vnd.ms-pkiseccatcat
application/vnd.ms-pkistlstl
application/vnd.ms-powerpointpot
application/vnd.ms-powerpointpps
application/vnd.ms-powerpointppt
application/vnd.ms-projectmpp
application/vnd.ms-workswcm
application/vnd.ms-workswdb
application/vnd.ms-workswks
application/vnd.ms-workswps
application/winhlphlp
application/x-bcpiobcpio
application/x-cdfcdf
application/x-compressz
application/x-compressedtgz
application/x-cpiocpio
application/x-cshcsh
application/x-directordcr
application/x-directordir
application/x-directordxr
application/x-dvidvi
application/x-gtargtar
application/x-gzipgz
application/x-hdfhdf
application/x-internet-signupins
application/x-internet-signupisp
application/x-iphoneiii
application/x-javascriptjs
application/x-latexlatex
application/x-msaccessmdb
application/x-mscardfilecrd
application/x-msclipclp
application/x-msdownloaddll
application/x-msmediaviewm13
application/x-msmediaviewm14
application/x-msmediaviewmvb
application/x-msmetafilewmf
application/x-msmoneymny
application/x-mspublisherpub
application/x-msschedulescd
application/x-msterminaltrm
application/x-mswritewri
application/x-netcdfcdf
application/x-netcdfnc
application/x-perfmonpma
application/x-perfmonpmc
application/x-perfmonpml
application/x-perfmonpmr
application/x-perfmonpmw
application/x-pkcs12p12
application/x-pkcs12pfx
application/x-pkcs7-certificatesp7b
application/x-pkcs7-certificatesspc
application/x-pkcs7-certreqrespp7r
application/x-pkcs7-mimep7c
application/x-pkcs7-mimep7m
application/x-pkcs7-signaturep7s
application/x-shsh
application/x-sharshar
application/x-shockwave-flashswf
application/x-stuffitsit
application/x-sv4cpiosv4cpio
application/x-sv4crcsv4crc
application/x-tartar
application/x-tcltcl
application/x-textex
application/x-texinfotexi
application/x-texinfotexinfo
application/x-troffroff
application/x-trofft
application/x-trofftr
application/x-troff-manman
application/x-troff-meme
application/x-troff-msms
application/x-ustarustar
application/x-wais-sourcesrc
application/x-x509-ca-certcer
application/x-x509-ca-certcrt
application/x-x509-ca-certder
application/ynd.ms-pkipkopko
application/zipzip
audio/basicau
audio/basicsnd
audio/midmid
audio/midrmi
audio/mpegmp3
audio/x-aiffaif
audio/x-aiffaifc
audio/x-aiffaiff
audio/x-mpegurlm3u
audio/x-pn-realaudiora
audio/x-pn-realaudioram
audio/x-wavwav
image/bmpbmp
image/cis-codcod
image/gifgif
image/iefief
image/jpegjpe
image/jpegjpeg
image/jpegjpg
image/pipegjfif
image/svg+xmlsvg
image/tifftif
image/tifftiff
image/x-cmu-rasterras
image/x-cmxcmx
image/x-iconico
image/x-portable-anymappnm
image/x-portable-bitmappbm
image/x-portable-graymappgm
image/x-portable-pixmapppm
image/x-rgbrgb
image/x-xbitmapxbm
image/x-xpixmapxpm
image/x-xwindowdumpxwd
message/rfc822mht
message/rfc822mhtml
message/rfc822nws
text/csscss
text/h323323
text/htmlhtm
text/htmlhtml
text/htmlstm
text/iulsuls
text/plainbas
text/plainc
text/plainh
text/plaintxt
text/richtextrtx
text/scriptletsct
text/tab-separated-valuestsv
text/webviewhtmlhtt
text/x-componenthtc
text/x-setextetx
text/x-vcardvcf
video/mpegmp2
video/mpegmpa
video/mpegmpe
video/mpegmpeg
video/mpegmpg
video/mpegmpv2
video/quicktimemov
video/quicktimeqt
video/x-la-asflsf
video/x-la-asflsx
video/x-ms-asfasf
video/x-ms-asfasr
video/x-ms-asfasx
video/x-msvideoavi
video/x-sgi-moviemovie
x-world/x-vrmlflr
x-world/x-vrmlvrml
x-world/x-vrmlwrl
x-world/x-vrmlwrz
x-world/x-vrmlxaf
x-world/x-vrmlxof

按照文件扩展名排列的 Mime 类型列表

扩展名类型/子类型
 application/octet-stream
323text/h323
acxapplication/internet-property-stream
aiapplication/postscript
aifaudio/x-aiff
aifcaudio/x-aiff
aiffaudio/x-aiff
asfvideo/x-ms-asf
asrvideo/x-ms-asf
asxvideo/x-ms-asf
auaudio/basic
avivideo/x-msvideo
axsapplication/olescript
bastext/plain
bcpioapplication/x-bcpio
binapplication/octet-stream
bmpimage/bmp
ctext/plain
catapplication/vnd.ms-pkiseccat
cdfapplication/x-cdf
cerapplication/x-x509-ca-cert
classapplication/octet-stream
clpapplication/x-msclip
cmximage/x-cmx
codimage/cis-cod
cpioapplication/x-cpio
crdapplication/x-mscardfile
crlapplication/pkix-crl
crtapplication/x-x509-ca-cert
cshapplication/x-csh
csstext/css
dcrapplication/x-director
derapplication/x-x509-ca-cert
dirapplication/x-director
dllapplication/x-msdownload
dmsapplication/octet-stream
docapplication/msword
dotapplication/msword
dviapplication/x-dvi
dxrapplication/x-director
epsapplication/postscript
etxtext/x-setext
evyapplication/envoy
exeapplication/octet-stream
fifapplication/fractals
flrx-world/x-vrml
gifimage/gif
gtarapplication/x-gtar
gzapplication/x-gzip
htext/plain
hdfapplication/x-hdf
hlpapplication/winhlp
hqxapplication/mac-binhex40
htaapplication/hta
htctext/x-component
htmtext/html
htmltext/html
htttext/webviewhtml
icoimage/x-icon
iefimage/ief
iiiapplication/x-iphone
insapplication/x-internet-signup
ispapplication/x-internet-signup
jfifimage/pipeg
jpeimage/jpeg
jpegimage/jpeg
jpgimage/jpeg
jsapplication/x-javascript
latexapplication/x-latex
lhaapplication/octet-stream
lsfvideo/x-la-asf
lsxvideo/x-la-asf
lzhapplication/octet-stream
m13application/x-msmediaview
m14application/x-msmediaview
m3uaudio/x-mpegurl
manapplication/x-troff-man
mdbapplication/x-msaccess
meapplication/x-troff-me
mhtmessage/rfc822
mhtmlmessage/rfc822
midaudio/mid
mnyapplication/x-msmoney
movvideo/quicktime
movievideo/x-sgi-movie
mp2video/mpeg
mp3audio/mpeg
mpavideo/mpeg
mpevideo/mpeg
mpegvideo/mpeg
mpgvideo/mpeg
mppapplication/vnd.ms-project
mpv2video/mpeg
msapplication/x-troff-ms
mvbapplication/x-msmediaview
nwsmessage/rfc822
odaapplication/oda
p10application/pkcs10
p12application/x-pkcs12
p7bapplication/x-pkcs7-certificates
p7capplication/x-pkcs7-mime
p7mapplication/x-pkcs7-mime
p7rapplication/x-pkcs7-certreqresp
p7sapplication/x-pkcs7-signature
pbmimage/x-portable-bitmap
pdfapplication/pdf
pfxapplication/x-pkcs12
pgmimage/x-portable-graymap
pkoapplication/ynd.ms-pkipko
pmaapplication/x-perfmon
pmcapplication/x-perfmon
pmlapplication/x-perfmon
pmrapplication/x-perfmon
pmwapplication/x-perfmon
pnmimage/x-portable-anymap
pot,application/vnd.ms-powerpoint
ppmimage/x-portable-pixmap
ppsapplication/vnd.ms-powerpoint
pptapplication/vnd.ms-powerpoint
prfapplication/pics-rules
psapplication/postscript
pubapplication/x-mspublisher
qtvideo/quicktime
raaudio/x-pn-realaudio
ramaudio/x-pn-realaudio
rasimage/x-cmu-raster
rgbimage/x-rgb
rmiaudio/mid
roffapplication/x-troff
rtfapplication/rtf
rtxtext/richtext
scdapplication/x-msschedule
scttext/scriptlet
setpayapplication/set-payment-initiation
setregapplication/set-registration-initiation
shapplication/x-sh
sharapplication/x-shar
sitapplication/x-stuffit
sndaudio/basic
spcapplication/x-pkcs7-certificates
splapplication/futuresplash
srcapplication/x-wais-source
sstapplication/vnd.ms-pkicertstore
stlapplication/vnd.ms-pkistl
stmtext/html
svgimage/svg+xml
sv4cpioapplication/x-sv4cpio
sv4crcapplication/x-sv4crc
swfapplication/x-shockwave-flash
tapplication/x-troff
tarapplication/x-tar
tclapplication/x-tcl
texapplication/x-tex
texiapplication/x-texinfo
texinfoapplication/x-texinfo
tgzapplication/x-compressed
tifimage/tiff
tiffimage/tiff
trapplication/x-troff
trmapplication/x-msterminal
tsvtext/tab-separated-values
txttext/plain
ulstext/iuls
ustarapplication/x-ustar
vcftext/x-vcard
vrmlx-world/x-vrml
wavaudio/x-wav
wcmapplication/vnd.ms-works
wdbapplication/vnd.ms-works
wksapplication/vnd.ms-works
wmfapplication/x-msmetafile
wpsapplication/vnd.ms-works
wriapplication/x-mswrite
wrlx-world/x-vrml
wrzx-world/x-vrml
xafx-world/x-vrml
xbmimage/x-xbitmap
xlaapplication/vnd.ms-excel
xlcapplication/vnd.ms-excel
xlmapplication/vnd.ms-excel
xlsapplication/vnd.ms-excel
xltapplication/vnd.ms-excel
xlwapplication/vnd.ms-excel
xofx-world/x-vrml
xpmimage/x-xpixmap
xwdimage/x-xwindowdump
zapplication/x-compress
zipapplication/zip

解决android自带蓝牙不能发送接收某些文件类型