1 settype

使用该函数表示要查找文件的mime类型(如*/*),这个和组件在manifest里定义的相对应,但在源代码里:

view plain copy to clipboard print ?
  1. public  Intent setData(Uri data) {  
  2.         mData = data;  
  3.         mType = null ;  
  4.         return   this ;  
  5.     }  

public Intent setData(Uri data) { mData = data; mType = null; return this; }

 

会将type设为null。

2 setdata

该函数的参数是uri,所以要将数据通过该函数传递时,记得要把数据转化为uri,如Uri.fromFile(new File("/mnt/sdcard/"))。

该函数源代码

view plain copy to clipboard print ?
  1. public  Intent setType(String type) {  
  2.         mData = null ;  
  3.         mType = type;  
  4.         return   this ;  
  5.     }  

public Intent setType(String type) { mData = null; mType = type; return this; }

 

3 所以要同时设置data和type的话只能用函数setdataandtype了

view plain copy to clipboard print ?
  1. public  Intent setDataAndType(Uri data, String type) {  
  2.         mData = data;  
  3.         mType = type;  
  4.         return   this ;  
  5.     }  

public Intent setDataAndType(Uri data, String type) { mData = data; mType = type; return this; }

 

目前还不是很明白Android这样做的原因,请高手指点指点,谢谢!

更多相关文章

  1. Android下setLatestEventInfo警告、Handler警告、SimpleDateForm
  2. Notification用法,注意API版本,API大于11的setLatestEventInfo()方
  3. android源代码编译
  4. Android(安卓)studio 点击按钮跳转到新的Activity
  5. 设备驱动-----Android关机流程总结
  6. 基于ffmpeg的Android播放器开源代码
  7. C基础—函数指针,联合体,枚举,结构体和结构体指针
  8. Android(安卓)MediaPlayer 分析- MediaPlayerService.cpp
  9. 箭头函数的基础使用

随机推荐

  1. 简单表单与css选择器实战案例
  2. 0628前端作业
  3. 今日套餐使用
  4. table表格的运用
  5. mysql优化器追踪示例
  6. 表单和CSS选择器的案例
  7. 伪类选择器+盒模型+icon的使用方法+百分
  8. 简单的3行3列布局和固定定位
  9. 7/30号作业
  10. 在线QQ客服的固定定位以及三行三列的定位