赞
踩
要研究一下联系人App通过Data Ability对外暴露的添加联系人接口是如何定义的。以下是访问内置照片App的相关代码,供参考:
dataAbilityHelper = DataAbilityHelper.creator(this);
try {
resultSet = dataAbilityHelper.query(AVStorage.Images.Media.EXTERNAL_DATA_ABILITY_URI,
new String[]{AVStorage.Images.Media.ID}, null);
if (resultSet != null) {
while (resultSet.goToNextRow()) {
int mediaId = resultSet.getInt(resultSet.getColumnIndexForName(AVStorage.Images.Media.ID));
Uri uri = DataUriUtils.attachId(AVStorage.Images.Media.EXTERNAL_DATA_ABILITY_URI, mediaId);
FileDescriptor fileDescriptor = dataAbilityHelper.openFile(uri, "r");
ImageSource imageSource = ImageSource.create(fileDescriptor, null);
ImageSource.DecodingOptions decodingOpts = new ImageSource.DecodingOptions();
decodingOpts.desiredSize = new Size(300, 300);
PixelMap pixelMap = imageSource.createThumbnailPixelmap(decodingOpts, true);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。