Android provides an Intent mechanism to assist in interaction and communication between applications. Or, to be more accurate, Intent can be used not only between applications, it can also be used for interaction between Activity/Service in an application. The granularity of software reuse implemented by Intent is Activity/Service, which is higher than function reuse, and the coupling is more loose.
1 settype
Use this function to indicate the mime type (such as */*) of the file to be searched. This corresponds to the definition of the component in manifest, but in the source code:
View plain copy to clipboard print?
Public Intent setData (Uri data ){
MData = data;
MType = null;
Return this;
}
View plain
Public Intent setData (Uri data ){
MData = data;
MType = null;
Return this;
}
Set type to null.
2 setdata
The parameter of this function is uri, so when you want to pass data through this function, remember to convert the data into a uri, such as Uri. fromFile (new File ("/mnt/sdcard /")).
Source code of the Function
View plain copy to clipboard print?
Public Intent setType (String type ){
MData = null;
MType = type;
Return this;
}
View plain
Public Intent setType (String type ){
MData = null;
MType = type;
Return this;
}
3. If you want to set both data and type, you can only use the setdataandtype function.
View plain copy to clipboard print?
Public Intent setDataAndType (Uri data, String type ){
MData = data;
MType = type;
Return this;
}
View plain
Public Intent setDataAndType (Uri data, String type ){
MData = data;
MType = type;
Return this;
}
Author "quding0308"