한 번에 두 개 이상의 이미지를 업로드 할 수있는 이미지 업 로더를 만들고 있습니다.Android - 어떻게 이미지를 ClipData에서 가져올 수 있습니까?
galerijButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, SELECT_PHOTO);
}
});
... 내가 ArrayList에 내 사진을 배열에 선택한 모든 이미지를 추가 할
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case SELECT_PHOTO:
if(resultCode == RESULT_OK){
if(imageReturnedIntent.getData() != null){
//If uploaded with Android Gallery (max 1 image)
Uri selectedImage = imageReturnedIntent.getData();
InputStream imageStream;
try {
imageStream = getContentResolver().openInputStream(selectedImage);
Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream);
photos.add(yourSelectedImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
} else {
//If uploaded with the new Android Photos gallery
ClipData clipData = imageReturnedIntent.getClipData();
for(int i = 0; i < clipData.getItemCount(); i++){
clipData.getItemAt(i);
//What now?
}
}
}
break;
....
. 어떻게 든 ClipData.Item 비트 맵으로 변환해야하지만 어떻게?
클립 보드에서 이미지를 복사하려고합니까? – SMR
아니요, Android 사진 앱을 사용하여 한 번에 여러 이미지를 업로드하고 있습니다. Android 포토 앱은 선택한 이미지를 (의도) imageReturnedIntent.getClipData(); 그 이유는 Array의 크기가 항상 선택된 이미지의 수이기 때문입니다. –