http://developer.android.com/training/sharing/send.html
http://developer.android.com/training/sharing/receive.html
ES浏览器过来的数据
[file:///sdcard/Vlog.xml, file:///sdcard/toolbox-stericson, file:///sdcard/videoEngine.log, file:///sdcard/python.zip]
三星自带文件管理器过来数据
file:///mnt/sdcard/ubuntu-11.10-desktop-amd64.iso
系统相册过来的数据
[content://media/external/images/media/748, content://media/external/images/media/744, content://media/external/images/media/743, content://media/external/images/media/742]
private void getShareData()
{
// Get intent, action and MIME type
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null)
{
handleSingleData(intent);
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null)
{
handleMultipleData(intent);
} else
{
LogUtil.d("Handle other intents");
// Handle other intents, such as being started from the home screen
}
}
private void handleMultipleData(Intent intent)
{
ArrayList<Parcelable> imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
for(Parcelable pa:imageUris){
Uri uri = (Uri)pa;
String scheme = uri.getScheme();
if(scheme.equals("content")){
ContentResolver cr = getContentResolver();
Cursor c = cr.query(uri,null,null,null,null);
c.moveToFirst();
String filePath = c.getString(c.getColumnIndexOrThrow(Images.Media.DATA));
c.close();
LogUtil.d("filePath = " + filePath);
}else if(scheme.equals("file"))
{
String filePath = uri.getPath();
LogUtil.d("filePath = " + filePath);
}
}
}
private void handleSingleData(Intent intent)
{
Uri uri = (Uri)intent.getExtras().getParcelable(Intent.EXTRA_STREAM);
String scheme = uri.getScheme();
if(scheme.equals("content")){
ContentResolver cr = getContentResolver();
Cursor c = cr.query(uri,null,null,null,null);
c.moveToFirst();
String filePath = c.getString(c.getColumnIndexOrThrow(Images.Media.DATA));
c.close();
LogUtil.d("filePath = " + filePath);
}else if(scheme.equals("file"))
{
String filePath = uri.getPath();
LogUtil.d("filePath = " + filePath);
}
}