Improved image picker for file transfer
This commit is contained in:
parent
88da3cac22
commit
844e5a1817
1 changed files with 8 additions and 8 deletions
|
@ -759,20 +759,20 @@ public class ChatActivity extends FragmentActivity implements OnClickListener, S
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pickImage() {
|
private void pickImage() {
|
||||||
final List<Intent> cameraIntents = new ArrayList<Intent>();
|
List<Intent> cameraIntents = new ArrayList<Intent>();
|
||||||
final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name));
|
File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name));
|
||||||
imageToUploadUri = Uri.fromFile(file);
|
imageToUploadUri = Uri.fromFile(file);
|
||||||
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri);
|
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri);
|
||||||
cameraIntents.add(captureIntent);
|
cameraIntents.add(captureIntent);
|
||||||
|
|
||||||
final Intent galleryIntent = new Intent();
|
Intent galleryIntent = new Intent();
|
||||||
galleryIntent.setType("image/*");
|
galleryIntent.setType("image/*");
|
||||||
galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
|
galleryIntent.setAction(Intent.ACTION_PICK);
|
||||||
|
|
||||||
final Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title));
|
Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title));
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));
|
||||||
|
|
||||||
startActivityForResult(chooserIntent, ADD_PHOTO);
|
startActivityForResult(chooserIntent, ADD_PHOTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue