本文整理匯總了Java中android.content.ClipData.addItem方法的典型用法代碼示例。如果您正苦於以下問題:Java ClipData.addItem方法的具體用法?Java ClipData.addItem怎麽用?Java ClipData.addItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.ClipData
的用法示例。
在下文中一共展示了ClipData.addItem方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onFinished
import android.content.ClipData; //導入方法依賴的package包/類
private void onFinished(Uri... uris) {
Log.d(TAG, "onFinished() " + Arrays.toString(uris));
final Intent intent = new Intent();
if (uris.length == 1) {
intent.setData(uris[0]);
} else if (uris.length > 1) {
final ClipData clipData = new ClipData(
null, mState.acceptMimes, new ClipData.Item(uris[0]));
for (int i = 1; i < uris.length; i++) {
clipData.addItem(new ClipData.Item(uris[i]));
}
if(Utils.hasJellyBean()){
intent.setClipData(clipData);
}
else{
intent.setData(uris[0]);
}
}
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
setResult(Activity.RESULT_OK, intent);
finish();
}
示例2: onFinished
import android.content.ClipData; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void onFinished(Uri... uris) {
Log.d(TAG, "onFinished() " + Arrays.toString(uris));
final Intent intent = new Intent();
if (uris.length == 1) {
intent.setData(uris[0]);
} else if (uris.length > 1) {
final ClipData clipData = new ClipData(
null, mState.acceptMimes, new ClipData.Item(uris[0]));
for (int i = 1; i < uris.length; i++) {
clipData.addItem(new ClipData.Item(uris[i]));
}
if(Utils.hasJellyBean()){
intent.setClipData(clipData);
}
else{
intent.setData(uris[0]);
}
}
if (mState.action == DocumentsActivity.State.ACTION_GET_CONTENT) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else if (mState.action == ACTION_OPEN_TREE) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
} else {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
}
setResult(Activity.RESULT_OK, intent);
finish();
}
示例3: createClipData
import android.content.ClipData; //導入方法依賴的package包/類
private ClipData createClipData(AlbumItem[] items) {
String[] mimeTypes = new String[items.length];
for (int i = 0; i < items.length; i++) {
mimeTypes[i] = MediaType.getMimeType(this, items[i].getUri(this));
}
ClipData clipData =
new ClipData("Images", mimeTypes,
new ClipData.Item(items[0].getUri(this)));
for (int i = 1; i < items.length; i++) {
clipData.addItem(new ClipData.Item(items[i].getUri(this)));
}
return clipData;
}