Android 应用程序之间内容分享详解(一)

大家好!很荣幸我能够成为CSDN 2013年度博客之星评选的候选人,希望继续得到大家的支持与鼓励,看到的朋友帮我投上宝贵的一票吧!

       投票地址:http://vote.blog.csdn.net/blogstaritem/blogstar2013/xiaanming



转载请注明地址:http://blog.csdn.net/xiaanming/article/details/9395991

Android 应用程序之间内容分享详解(二)


一个Andoird应用程序的重要的地方是他们有相互沟通和整合的能力,一个应用程序可以和另一个应用程序交互,接下来我们来看看Android应用之间的内容分享

当你构建Intent的时候,必须要指定Intent的Action触发,定义Intent的Action例如ACTION_SEND,你大概可以猜到指定Action为ACTION_SEND的Intent的作用是从一个Activity发送数据到另一个Activity,甚至跨越不同的进程,将数据发送给另一个Activity,你需要指定数据和他的类型,系统将识别接收的Activity,并显示他们给用户(假如有多个选择的时候)或者立即启动Activity(只要一个选择的时候)

1.发送文本内容


最直接最常用的是用ACTION_SEND来从一个应用发送文本内容到另一个应用,例如,我们的内置浏览器可以与任何页面当前的URL来共享文字,下面的例子就是共享文本内容

[java] view plain copy
  1. Intent sendIntent = new Intent();  
  2. sendIntent.setAction(Intent.ACTION_SEND);  
  3. //这里是你发送的文本  
  4. sendIntent.putExtra(Intent.EXTRA_TEXT, "我用手机测试分享内容");  
  5. sendIntent.setType("text/plain");  
  6. startActivity(sendIntent);  
假如你安装了过滤Action为ACTION_SEND,MIMEtype为“text/plain”的应用程序,这个系统就会启动,假如系统匹配到多个这样子的应用程序,他就会弹出一个Dialog列出所有的应用供用户选择(一个选择器),如下图

Android 应用程序之间内容分享详解(一)_第1张图片

可能你觉得上面的代码很简单,我很容易就能写出来,可是你发现了没有,当我们的手机里面没有地图类型的应用程序,你执行startActivity方法,你的程序就会出现Crash(崩溃),所以我们需要先判断下系统是否有这类型的应用程序,判断也很简单

[java] view plain copy
  1. public boolean hasApplication(Intent intent){    
  2.         PackageManager packageManager = getPackageManager();    
  3.         //查询是否有该Intent的Activity    
  4.         List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);    
  5.         //activities里面不为空就有,否则就没有    
  6.         return activities.size() > 0 ? true : false;    
所以我们在startActivity的时候要做上面的判断,这样子我们开发出来的程序才会更加的健壮,少一些Crash用户体验也会更好,假如每次都要判断你师傅会觉得烦?所以我们也可以使用Intent的Intent.createChooser方法

他有如下优点

  • 1.1 即使用户选择了默认的方式,选择器仍然会弹出来
  • 1.2 如果没有匹配到这样的应用程序,系统就会提示消息
  • 1.3 你可以指定选择器Dialog的标题

[java] view plain copy
  1. Intent sendIntent = new Intent();  
  2. sendIntent.setAction(Intent.ACTION_SEND);  
  3. sendIntent.putExtra(Intent.EXTRA_TEXT, "我用手机测试分享内容");  
  4. sendIntent.setType("text/plain");  
  5. startActivity(Intent.createChooser(sendIntent, "我是弹出框的标题"));  


注:某些邮件类应用程序,如Gmail,我们可以使用putExtra(Intent.EXTRA_EMAIL, String[]) 添加一个字符串数组到Intent中


2.发送二进制内容


二进制内容的共享使用Action为ACTION_SEND,在设置适当的MIME类型,并且添加putExtra(Intent.EXTRA_STREAM, URI),下面是一个常用的共享图片的代码,也可以共享任何类型的二进制内容

[java] view plain copy
  1. Intent shareIntent = new Intent();  
  2. shareIntent.setAction(Intent.ACTION_SEND);  
  3. shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);  
  4. shareIntent.setType("image/jpeg");  
  5. startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));  
主要下面几点
  • 你可以使用MIME type为“ */*” ,他只会匹配处理一般数据流的Activity
  • 接收应用程序需要Uri指定数据的访问权限
  1. 在SD卡的文件,我们使用File file = new File(filePath); Uri.fromFile(file),然后把他传递给Intent
  2. 在应用程序的目录中,openFileOutput的模式为MODE_WORLD_READABLE,然后我们可以使用getFileStreamPath()返回一个File,然后利用Uri.fromFile(file)传递给Intent
  3. 可以扫描图像,视频和音频等媒体文件,添加到系统MediaStore使用SCANFILE()来扫描文件,扫描完成后会调用 onScanCompleted()回调方法来返回一个Uri
  4. 图片使用insertImage()方法插入到系统MediaStore也会返回一个图片的Uri

下面是共享图片的例子

[java] view plain copy
  1. Intent shareIntent = new Intent();  
  2. shareIntent.setAction(Intent.ACTION_SEND);  
  3. File file = new File("mnt/sdcard/share.png");  
  4.               
  5. System.out.println(Uri.fromFile(file));  
  6. shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));  
  7. shareIntent.setType("image/jpeg");  
  8. startActivity(Intent.createChooser(shareIntent, "共享图片"));  


选择QQ空间后,图片就显示在那里了,如下图

Android 应用程序之间内容分享详解(一)_第2张图片

我们要共享多个二进制内容利用Action为ACTION_SEND_MULTIPLE,下面是我们共享多张图片

[java] view plain copy
  1. ArrayList<Uri> imageUris = new ArrayList<Uri>();  
  2. imageUris.add(imageUri1); // Add your image URIs here  
  3. imageUris.add(imageUri2);  
  4.   
  5. Intent shareIntent = new Intent();  
  6. shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);  
  7. shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);  
  8. shareIntent.setType("image/*");  
  9. startActivity(Intent.createChooser(shareIntent, "Share images to.."));  

下面我列出几个常用的MIME type类型

  • text/plain(纯文本)
  • text/html(HTML文档)
  • application/xhtml+xml(XHTML文档)
  • image/gif(GIF图像)
  • image/jpeg(JPEG图像)【PHP中为:image/pjpeg】
  • image/png(PNG图像)【PHP中为:image/x-png】
  • video/mpeg(MPEG动画)
  • application/octet-stream(任意的二进制数据)
  • application/pdf(PDF文档)
  • application/msword(Microsoft Word文件)
  • message/rfc822(RFC 822形式)
  • multipart/alternative(HTML邮件的HTML形式和纯文本形式,相同内容使用不同形式表示)
  • application/x-www-form-urlencoded(使用HTTP的POST方法提交的表单)
  • multipart/form-data(同上,但主要用于表单提交时伴随文件上传的场合)

Android所有支持的MIME type

[java] view plain copy
  1. <span style="white-space:pre">      </span>sMimeTypeMap.loadEntry("application/andrew-inset""ez");  
  2.            sMimeTypeMap.loadEntry("application/dsptype""tsp");  
  3.            sMimeTypeMap.loadEntry("application/futuresplash""spl");  
  4.            sMimeTypeMap.loadEntry("application/hta""hta");  
  5.            sMimeTypeMap.loadEntry("application/mac-binhex40""hqx");  
  6.            sMimeTypeMap.loadEntry("application/mac-compactpro""cpt");  
  7.            sMimeTypeMap.loadEntry("application/mathematica""nb");  
  8.            sMimeTypeMap.loadEntry("application/msaccess""mdb");  
  9.            sMimeTypeMap.loadEntry("application/oda""oda");  
  10.            sMimeTypeMap.loadEntry("application/ogg""ogg");  
  11.            sMimeTypeMap.loadEntry("application/pdf""pdf");  
  12.            sMimeTypeMap.loadEntry("application/pgp-keys""key");  
  13.            sMimeTypeMap.loadEntry("application/pgp-signature""pgp");  
  14.            sMimeTypeMap.loadEntry("application/pics-rules""prf");  
  15.            sMimeTypeMap.loadEntry("application/rar""rar");  
  16.            sMimeTypeMap.loadEntry("application/rdf+xml""rdf");  
  17.            sMimeTypeMap.loadEntry("application/rss+xml""rss");  
  18.            sMimeTypeMap.loadEntry("application/zip""zip");  
  19.            sMimeTypeMap.loadEntry("application/vnd.android.package-archive",   
  20.                    "apk");  
  21.            sMimeTypeMap.loadEntry("application/vnd.cinderella""cdy");  
  22.            sMimeTypeMap.loadEntry("application/vnd.ms-pki.stl""stl");  
  23.            sMimeTypeMap.loadEntry(  
  24.                    "application/vnd.oasis.opendocument.database""odb");  
  25.            sMimeTypeMap.loadEntry(  
  26.                    "application/vnd.oasis.opendocument.formula""odf");  
  27.            sMimeTypeMap.loadEntry(  
  28.                    "application/vnd.oasis.opendocument.graphics""odg");  
  29.            sMimeTypeMap.loadEntry(  
  30.                    "application/vnd.oasis.opendocument.graphics-template",  
  31.                    "otg");  
  32.            sMimeTypeMap.loadEntry(  
  33.                    "application/vnd.oasis.opendocument.image""odi");  
  34.            sMimeTypeMap.loadEntry(  
  35.                    "application/vnd.oasis.opendocument.spreadsheet""ods");  
  36.            sMimeTypeMap.loadEntry(  
  37.                    "application/vnd.oasis.opendocument.spreadsheet-template",  
  38.                    "ots");  
  39.            sMimeTypeMap.loadEntry(  
  40.                    "application/vnd.oasis.opendocument.text""odt");  
  41.            sMimeTypeMap.loadEntry(  
  42.                    "application/vnd.oasis.opendocument.text-master""odm");  
  43.            sMimeTypeMap.loadEntry(  
  44.                    "application/vnd.oasis.opendocument.text-template""ott");  
  45.            sMimeTypeMap.loadEntry(  
  46.                    "application/vnd.oasis.opendocument.text-web""oth");  
  47.            sMimeTypeMap.loadEntry("application/msword""doc");  
  48.            sMimeTypeMap.loadEntry("application/msword""dot");  
  49.            sMimeTypeMap.loadEntry(  
  50.                    "application/vnd.openxmlformats-officedocument.wordprocessingml.document",  
  51.                    "docx");  
  52.            sMimeTypeMap.loadEntry(  
  53.                    "application/vnd.openxmlformats-officedocument.wordprocessingml.template",  
  54.                    "dotx");  
  55.            sMimeTypeMap.loadEntry("application/vnd.ms-excel""xls");  
  56.            sMimeTypeMap.loadEntry("application/vnd.ms-excel""xlt");  
  57.            sMimeTypeMap.loadEntry(  
  58.                    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",  
  59.                    "xlsx");  
  60.            sMimeTypeMap.loadEntry(  
  61.                    "application/vnd.openxmlformats-officedocument.spreadsheetml.template",  
  62.                    "xltx");  
  63.            sMimeTypeMap.loadEntry("application/vnd.ms-powerpoint""ppt");  
  64.            sMimeTypeMap.loadEntry("application/vnd.ms-powerpoint""pot");  
  65.            sMimeTypeMap.loadEntry("application/vnd.ms-powerpoint""pps");  
  66.            sMimeTypeMap.loadEntry(  
  67.                    "application/vnd.openxmlformats-officedocument.presentationml.presentation",  
  68.                    "pptx");  
  69.            sMimeTypeMap.loadEntry(  
  70.                    "application/vnd.openxmlformats-officedocument.presentationml.template",  
  71.                    "potx");  
  72.            sMimeTypeMap.loadEntry(  
  73.                    "application/vnd.openxmlformats-officedocument.presentationml.slideshow",  
  74.                    "ppsx");  
  75.            sMimeTypeMap.loadEntry("application/vnd.rim.cod""cod");  
  76.            sMimeTypeMap.loadEntry("application/vnd.smaf""mmf");  
  77.            sMimeTypeMap.loadEntry("application/vnd.stardivision.calc""sdc");  
  78.            sMimeTypeMap.loadEntry("application/vnd.stardivision.draw""sda");  
  79.            sMimeTypeMap.loadEntry(  
  80.                    "application/vnd.stardivision.impress""sdd");  
  81.            sMimeTypeMap.loadEntry(  
  82.                    "application/vnd.stardivision.impress""sdp");  
  83.            sMimeTypeMap.loadEntry("application/vnd.stardivision.math""smf");  
  84.            sMimeTypeMap.loadEntry("application/vnd.stardivision.writer",  
  85.                    "sdw");  
  86.            sMimeTypeMap.loadEntry("application/vnd.stardivision.writer",  
  87.                    "vor");  
  88.            sMimeTypeMap.loadEntry(  
  89.                    "application/vnd.stardivision.writer-global""sgl");  
  90.            sMimeTypeMap.loadEntry("application/vnd.sun.xml.calc""sxc");  
  91.            sMimeTypeMap.loadEntry(  
  92.                    "application/vnd.sun.xml.calc.template""stc");  
  93.            sMimeTypeMap.loadEntry("application/vnd.sun.xml.draw""sxd");  
  94.            sMimeTypeMap.loadEntry(  
  95.                    "application/vnd.sun.xml.draw.template""std");  
  96.            sMimeTypeMap.loadEntry("application/vnd.sun.xml.impress""sxi");  
  97.            sMimeTypeMap.loadEntry(  
  98.                    "application/vnd.sun.xml.impress.template""sti");  
  99.            sMimeTypeMap.loadEntry("application/vnd.sun.xml.math""sxm");  
  100.            sMimeTypeMap.loadEntry("application/vnd.sun.xml.writer""sxw");  
  101.            sMimeTypeMap.loadEntry(  
  102.                    "application/vnd.sun.xml.writer.global""sxg");  
  103.            sMimeTypeMap.loadEntry(  
  104.                    "application/vnd.sun.xml.writer.template""stw");  
  105.            sMimeTypeMap.loadEntry("application/vnd.visio""vsd");  
  106.            sMimeTypeMap.loadEntry("application/x-abiword""abw");  
  107.            sMimeTypeMap.loadEntry("application/x-apple-diskimage""dmg");  
  108.            sMimeTypeMap.loadEntry("application/x-bcpio""bcpio");  
  109.            sMimeTypeMap.loadEntry("application/x-bittorrent""torrent");  
  110.            sMimeTypeMap.loadEntry("application/x-cdf""cdf");  
  111.            sMimeTypeMap.loadEntry("application/x-cdlink""vcd");  
  112.            sMimeTypeMap.loadEntry("application/x-chess-pgn""pgn");  
  113.            sMimeTypeMap.loadEntry("application/x-cpio""cpio");  
  114.            sMimeTypeMap.loadEntry("application/x-debian-package""deb");  
  115.            sMimeTypeMap.loadEntry("application/x-debian-package""udeb");  
  116.            sMimeTypeMap.loadEntry("application/x-director""dcr");  
  117.            sMimeTypeMap.loadEntry("application/x-director""dir");  
  118.            sMimeTypeMap.loadEntry("application/x-director""dxr");  
  119.            sMimeTypeMap.loadEntry("application/x-dms""dms");  
  120.            sMimeTypeMap.loadEntry("application/x-doom""wad");  
  121.            sMimeTypeMap.loadEntry("application/x-dvi""dvi");  
  122.            sMimeTypeMap.loadEntry("application/x-flac""flac");  
  123.            sMimeTypeMap.loadEntry("application/x-font""pfa");  
  124.            sMimeTypeMap.loadEntry("application/x-font""pfb");  
  125.            sMimeTypeMap.loadEntry("application/x-font""gsf");  
  126.            sMimeTypeMap.loadEntry("application/x-font""pcf");  
  127.            sMimeTypeMap.loadEntry("application/x-font""pcf.Z");  
  128.            sMimeTypeMap.loadEntry("application/x-freemind""mm");  
  129.            sMimeTypeMap.loadEntry("application/x-futuresplash""spl");  
  130.            sMimeTypeMap.loadEntry("application/x-gnumeric""gnumeric");  
  131.            sMimeTypeMap.loadEntry("application/x-go-sgf""sgf");  
  132.            sMimeTypeMap.loadEntry("application/x-graphing-calculator""gcf");  
  133.            sMimeTypeMap.loadEntry("application/x-gtar""gtar");  
  134.            sMimeTypeMap.loadEntry("application/x-gtar""tgz");  
  135.            sMimeTypeMap.loadEntry("application/x-gtar""taz");  
  136.            sMimeTypeMap.loadEntry("application/x-hdf""hdf");  
  137.            sMimeTypeMap.loadEntry("application/x-ica""ica");  
  138.            sMimeTypeMap.loadEntry("application/x-internet-signup""ins");  
  139.            sMimeTypeMap.loadEntry("application/x-internet-signup""isp");  
  140.            sMimeTypeMap.loadEntry("application/x-iphone""iii");  
  141.            sMimeTypeMap.loadEntry("application/x-iso9660-image""iso");  
  142.            sMimeTypeMap.loadEntry("application/x-jmol""jmz");  
  143.            sMimeTypeMap.loadEntry("application/x-kchart""chrt");  
  144.            sMimeTypeMap.loadEntry("application/x-killustrator""kil");  
  145.            sMimeTypeMap.loadEntry("application/x-koan""skp");  
  146.            sMimeTypeMap.loadEntry("application/x-koan""skd");  
  147.            sMimeTypeMap.loadEntry("application/x-koan""skt");  
  148.            sMimeTypeMap.loadEntry("application/x-koan""skm");  
  149.            sMimeTypeMap.loadEntry("application/x-kpresenter""kpr");  
  150.            sMimeTypeMap.loadEntry("application/x-kpresenter""kpt");  
  151.            sMimeTypeMap.loadEntry("application/x-kspread""ksp");  
  152.            sMimeTypeMap.loadEntry("application/x-kword""kwd");  
  153.            sMimeTypeMap.loadEntry("application/x-kword""kwt");  
  154.            sMimeTypeMap.loadEntry("application/x-latex""latex");  
  155.            sMimeTypeMap.loadEntry("application/x-lha""lha");  
  156.            sMimeTypeMap.loadEntry("application/x-lzh""lzh");  
  157.            sMimeTypeMap.loadEntry("application/x-lzx""lzx");  
  158.            sMimeTypeMap.loadEntry("application/x-maker""frm");  
  159.            sMimeTypeMap.loadEntry("application/x-maker""maker");  
  160.            sMimeTypeMap.loadEntry("application/x-maker""frame");  
  161.            sMimeTypeMap.loadEntry("application/x-maker""fb");  
  162.            sMimeTypeMap.loadEntry("application/x-maker""book");  
  163.            sMimeTypeMap.loadEntry("application/x-maker""fbdoc");  
  164.            sMimeTypeMap.loadEntry("application/x-mif""mif");  
  165.            sMimeTypeMap.loadEntry("application/x-ms-wmd""wmd");  
  166.            sMimeTypeMap.loadEntry("application/x-ms-wmz""wmz");  
  167.            sMimeTypeMap.loadEntry("application/x-msi""msi");  
  168.            sMimeTypeMap.loadEntry("application/x-ns-proxy-autoconfig""pac");  
  169.            sMimeTypeMap.loadEntry("application/x-nwc""nwc");  
  170.            sMimeTypeMap.loadEntry("application/x-object""o");  
  171.            sMimeTypeMap.loadEntry("application/x-oz-application""oza");  
  172.            sMimeTypeMap.loadEntry("application/x-pkcs12""p12");  
  173.            sMimeTypeMap.loadEntry("application/x-pkcs7-certreqresp""p7r");  
  174.            sMimeTypeMap.loadEntry("application/x-pkcs7-crl""crl");  
  175.            sMimeTypeMap.loadEntry("application/x-quicktimeplayer""qtl");  
  176.            sMimeTypeMap.loadEntry("application/x-shar""shar");  
  177.            sMimeTypeMap.loadEntry("application/x-shockwave-flash""swf");  
  178.            sMimeTypeMap.loadEntry("application/x-stuffit""sit");  
  179.            sMimeTypeMap.loadEntry("application/x-sv4cpio""sv4cpio");  
  180.            sMimeTypeMap.loadEntry("application/x-sv4crc""sv4crc");  
  181.            sMimeTypeMap.loadEntry("application/x-tar""tar");  
  182.            sMimeTypeMap.loadEntry("application/x-texinfo""texinfo");  
  183.            sMimeTypeMap.loadEntry("application/x-texinfo""texi");  
  184.            sMimeTypeMap.loadEntry("application/x-troff""t");  
  185.            sMimeTypeMap.loadEntry("application/x-troff""roff");  
  186.            sMimeTypeMap.loadEntry("application/x-troff-man""man");  
  187.            sMimeTypeMap.loadEntry("application/x-ustar""ustar");  
  188.            sMimeTypeMap.loadEntry("application/x-wais-source""src");  
  189.            sMimeTypeMap.loadEntry("application/x-wingz""wz");  
  190.            sMimeTypeMap.loadEntry("application/x-webarchive""webarchive");  
  191.            sMimeTypeMap.loadEntry("application/x-x509-ca-cert""crt");  
  192.            sMimeTypeMap.loadEntry("application/x-x509-user-cert""crt");  
  193.            sMimeTypeMap.loadEntry("application/x-xcf""xcf");  
  194.            sMimeTypeMap.loadEntry("application/x-xfig""fig");  
  195.            sMimeTypeMap.loadEntry("application/xhtml+xml""xhtml");  
  196.            sMimeTypeMap.loadEntry("audio/3gpp""3gpp");  
  197.            sMimeTypeMap.loadEntry("audio/basic""snd");  
  198.            sMimeTypeMap.loadEntry("audio/midi""mid");  
  199.            sMimeTypeMap.loadEntry("audio/midi""midi");  
  200.            sMimeTypeMap.loadEntry("audio/midi""kar");  
  201.            sMimeTypeMap.loadEntry("audio/mpeg""mpga");  
  202.            sMimeTypeMap.loadEntry("audio/mpeg""mpega");  
  203.            sMimeTypeMap.loadEntry("audio/mpeg""mp2");  
  204.            sMimeTypeMap.loadEntry("audio/mpeg""mp3");  
  205.            sMimeTypeMap.loadEntry("audio/mpeg""m4a");  
  206.            sMimeTypeMap.loadEntry("audio/mpegurl""m3u");  
  207.            sMimeTypeMap.loadEntry("audio/prs.sid""sid");  
  208.            sMimeTypeMap.loadEntry("audio/x-aiff""aif");  
  209.            sMimeTypeMap.loadEntry("audio/x-aiff""aiff");  
  210.            sMimeTypeMap.loadEntry("audio/x-aiff""aifc");  
  211.            sMimeTypeMap.loadEntry("audio/x-gsm""gsm");  
  212.            sMimeTypeMap.loadEntry("audio/x-mpegurl""m3u");  
  213.            sMimeTypeMap.loadEntry("audio/x-ms-wma""wma");  
  214.            sMimeTypeMap.loadEntry("audio/x-ms-wax""wax");  
  215.            sMimeTypeMap.loadEntry("audio/x-pn-realaudio""ra");  
  216.            sMimeTypeMap.loadEntry("audio/x-pn-realaudio""rm");  
  217.            sMimeTypeMap.loadEntry("audio/x-pn-realaudio""ram");  
  218.            sMimeTypeMap.loadEntry("audio/x-realaudio""ra");  
  219.            sMimeTypeMap.loadEntry("audio/x-scpls""pls");  
  220.            sMimeTypeMap.loadEntry("audio/x-sd2""sd2");  
  221.            sMimeTypeMap.loadEntry("audio/x-wav""wav");  
  222.            sMimeTypeMap.loadEntry("image/bmp""bmp");  
  223.            sMimeTypeMap.loadEntry("image/gif""gif");  
  224.            sMimeTypeMap.loadEntry("image/ico""cur");  
  225.            sMimeTypeMap.loadEntry("image/ico""ico");  
  226.            sMimeTypeMap.loadEntry("image/ief""ief");  
  227.            sMimeTypeMap.loadEntry("image/jpeg""jpeg");  
  228.            sMimeTypeMap.loadEntry("image/jpeg""jpg");  
  229.            sMimeTypeMap.loadEntry("image/jpeg""jpe");  
  230.            sMimeTypeMap.loadEntry("image/pcx""pcx");  
  231.            sMimeTypeMap.loadEntry("image/png""png");  
  232.            sMimeTypeMap.loadEntry("image/svg+xml""svg");  
  233.            sMimeTypeMap.loadEntry("image/svg+xml""svgz");  
  234.            sMimeTypeMap.loadEntry("image/tiff""tiff");  
  235.            sMimeTypeMap.loadEntry("image/tiff""tif");  
  236.            sMimeTypeMap.loadEntry("image/vnd.djvu""djvu");  
  237.            sMimeTypeMap.loadEntry("image/vnd.djvu""djv");  
  238.            sMimeTypeMap.loadEntry("image/vnd.wap.wbmp""wbmp");  
  239.            sMimeTypeMap.loadEntry("image/x-cmu-raster""ras");  
  240.            sMimeTypeMap.loadEntry("image/x-coreldraw""cdr");  
  241.            sMimeTypeMap.loadEntry("image/x-coreldrawpattern""pat");  
  242.            sMimeTypeMap.loadEntry("image/x-coreldrawtemplate""cdt");  
  243.            sMimeTypeMap.loadEntry("image/x-corelphotopaint""cpt");  
  244.            sMimeTypeMap.loadEntry("image/x-icon""ico");  
  245.            sMimeTypeMap.loadEntry("image/x-jg""art");  
  246.            sMimeTypeMap.loadEntry("image/x-jng""jng");  
  247.            sMimeTypeMap.loadEntry("image/x-ms-bmp""bmp");  
  248.            sMimeTypeMap.loadEntry("image/x-photoshop""psd");  
  249.            sMimeTypeMap.loadEntry("image/x-portable-anymap""pnm");  
  250.            sMimeTypeMap.loadEntry("image/x-portable-bitmap""pbm");  
  251.            sMimeTypeMap.loadEntry("image/x-portable-graymap""pgm");  
  252.            sMimeTypeMap.loadEntry("image/x-portable-pixmap""ppm");  
  253.            sMimeTypeMap.loadEntry("image/x-rgb""rgb");  
  254.            sMimeTypeMap.loadEntry("image/x-xbitmap""xbm");  
  255.            sMimeTypeMap.loadEntry("image/x-xpixmap""xpm");  
  256.            sMimeTypeMap.loadEntry("image/x-xwindowdump""xwd");  
  257.            sMimeTypeMap.loadEntry("model/iges""igs");  
  258.            sMimeTypeMap.loadEntry("model/iges""iges");  
  259.            sMimeTypeMap.loadEntry("model/mesh""msh");  
  260.            sMimeTypeMap.loadEntry("model/mesh""mesh");  
  261.            sMimeTypeMap.loadEntry("model/mesh""silo");  
  262.            sMimeTypeMap.loadEntry("text/calendar""ics");  
  263.            sMimeTypeMap.loadEntry("text/calendar""icz");  
  264.            sMimeTypeMap.loadEntry("text/comma-separated-values""csv");  
  265.            sMimeTypeMap.loadEntry("text/css""css");  
  266.            sMimeTypeMap.loadEntry("text/html""htm");  
  267.            sMimeTypeMap.loadEntry("text/html""html");  
  268.            sMimeTypeMap.loadEntry("text/h323""323");  
  269.            sMimeTypeMap.loadEntry("text/iuls""uls");  
  270.            sMimeTypeMap.loadEntry("text/mathml""mml");  
  271.            // add it first so it will be the default for ExtensionFromMimeType  
  272.            sMimeTypeMap.loadEntry("text/plain""txt");  
  273.            sMimeTypeMap.loadEntry("text/plain""asc");  
  274.            sMimeTypeMap.loadEntry("text/plain""text");  
  275.            sMimeTypeMap.loadEntry("text/plain""diff");  
  276.            sMimeTypeMap.loadEntry("text/plain""po");     // reserve "pot" for vnd.ms-powerpoint  
  277.            sMimeTypeMap.loadEntry("text/richtext""rtx");  
  278.            sMimeTypeMap.loadEntry("text/rtf""rtf");  
  279.            sMimeTypeMap.loadEntry("text/texmacs""ts");  
  280.            sMimeTypeMap.loadEntry("text/text""phps");  
  281.            sMimeTypeMap.loadEntry("text/tab-separated-values""tsv");  
  282.            sMimeTypeMap.loadEntry("text/xml""xml");  
  283.            sMimeTypeMap.loadEntry("text/x-bibtex""bib");  
  284.            sMimeTypeMap.loadEntry("text/x-boo""boo");  
  285.            sMimeTypeMap.loadEntry("text/x-c++hdr""h++");  
  286.            sMimeTypeMap.loadEntry("text/x-c++hdr""hpp");  
  287.            sMimeTypeMap.loadEntry("text/x-c++hdr""hxx");  
  288.            sMimeTypeMap.loadEntry("text/x-c++hdr""hh");  
  289.            sMimeTypeMap.loadEntry("text/x-c++src""c++");  
  290.            sMimeTypeMap.loadEntry("text/x-c++src""cpp");  
  291.            sMimeTypeMap.loadEntry("text/x-c++src""cxx");  
  292.            sMimeTypeMap.loadEntry("text/x-chdr""h");  
  293.            sMimeTypeMap.loadEntry("text/x-component""htc");  
  294.            sMimeTypeMap.loadEntry("text/x-csh""csh");  
  295.            sMimeTypeMap.loadEntry("text/x-csrc""c");  
  296.            sMimeTypeMap.loadEntry("text/x-dsrc""d");  
  297.            sMimeTypeMap.loadEntry("text/x-haskell""hs");  
  298.            sMimeTypeMap.loadEntry("text/x-java""java");  
  299.            sMimeTypeMap.loadEntry("text/x-literate-haskell""lhs");  
  300.            sMimeTypeMap.loadEntry("text/x-moc""moc");  
  301.            sMimeTypeMap.loadEntry("text/x-pascal""p");  
  302.            sMimeTypeMap.loadEntry("text/x-pascal""pas");  
  303.            sMimeTypeMap.loadEntry("text/x-pcs-gcd""gcd");  
  304.            sMimeTypeMap.loadEntry("text/x-setext""etx");  
  305.            sMimeTypeMap.loadEntry("text/x-tcl""tcl");  
  306.            sMimeTypeMap.loadEntry("text/x-tex""tex");  
  307.            sMimeTypeMap.loadEntry("text/x-tex""ltx");  
  308.            sMimeTypeMap.loadEntry("text/x-tex""sty");  
  309.            sMimeTypeMap.loadEntry("text/x-tex""cls");  
  310.            sMimeTypeMap.loadEntry("text/x-vcalendar""vcs");  
  311.            sMimeTypeMap.loadEntry("text/x-vcard""vcf");  
  312.            sMimeTypeMap.loadEntry("video/3gpp""3gpp");  
  313.            sMimeTypeMap.loadEntry("video/3gpp""3gp");  
  314.            sMimeTypeMap.loadEntry("video/3gpp""3g2");  
  315.            sMimeTypeMap.loadEntry("video/dl""dl");  
  316.            sMimeTypeMap.loadEntry("video/dv""dif");  
  317.            sMimeTypeMap.loadEntry("video/dv""dv");  
  318.            sMimeTypeMap.loadEntry("video/fli""fli");  
  319.            sMimeTypeMap.loadEntry("video/m4v""m4v");  
  320.            sMimeTypeMap.loadEntry("video/mpeg""mpeg");  
  321.            sMimeTypeMap.loadEntry("video/mpeg""mpg");  
  322.            sMimeTypeMap.loadEntry("video/mpeg""mpe");  
  323.            sMimeTypeMap.loadEntry("video/mp4""mp4");  
  324.            sMimeTypeMap.loadEntry("video/mpeg""VOB");  
  325.            sMimeTypeMap.loadEntry("video/quicktime""qt");  
  326.            sMimeTypeMap.loadEntry("video/quicktime""mov");  
  327.            sMimeTypeMap.loadEntry("video/vnd.mpegurl""mxu");  
  328.            sMimeTypeMap.loadEntry("video/x-la-asf""lsf");  
  329.            sMimeTypeMap.loadEntry("video/x-la-asf""lsx");  
  330.            sMimeTypeMap.loadEntry("video/x-mng""mng");  
  331.            sMimeTypeMap.loadEntry("video/x-ms-asf""asf");  
  332.            sMimeTypeMap.loadEntry("video/x-ms-asf""asx");  
  333.            sMimeTypeMap.loadEntry("video/x-ms-wm""wm");  
  334.            sMimeTypeMap.loadEntry("video/x-ms-wmv""wmv");  
  335.            sMimeTypeMap.loadEntry("video/x-ms-wmx""wmx");  
  336.            sMimeTypeMap.loadEntry("video/x-ms-wvx""wvx");  
  337.            sMimeTypeMap.loadEntry("video/x-msvideo""avi");  
  338.            sMimeTypeMap.loadEntry("video/x-sgi-movie""movie");  
  339.            sMimeTypeMap.loadEntry("x-conference/x-cooltalk""ice");  
  340.            sMimeTypeMap.loadEntry("x-epoc/x-sisx-app""sisx");  


上面是发送内容给其他的应用程序,接下来我们分享从其他的应用接收内容用来显示,谢谢大家的关注!

你可能感兴趣的:(Android 应用程序之间内容分享详解(一))