Comments (4)
You can custom my library to meet your expectation!
In ImagePickerActivity, modify onActivityResult method like this:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Constants.REQUEST_CODE_CAPTURE) {
if (resultCode == RESULT_OK) {
if (fileTemp != null && fileTemp.exists()) {
MediaScannerConnection.scanFile(this,
new String[]{fileTemp.getAbsolutePath()}, null,
new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
Log.v("MediaScanWork", "file " + path
+ " was scanned successfully: " + uri);
Image image = new Image(0,"",path,false);
ArrayList<Image> images = new ArrayList<Image>();
images.add(image);
Intent data = new Intent();
data.putParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES, images);
setResult(RESULT_OK, data);
finish();
// getDataWithPermission();
}
});
}
}
}
}
After you capture an image in SINGLE mode, the ImagePickerActivity will be finished and return the captured image!
Please feel free to ask me any question!
from imagepicker.
@YasirAmeen Is your question answered? If yes - please close this issue.
from imagepicker.
@nguyenhoanglam I think the question is answered.
from imagepicker.
Hi,
My project is capturing image from the camera and set it in ImageView. Later, it has to be uploaded to the database. Image picker from the gallery is working fine but am getting an error with camera intent. Can you please help me with correct code.
My code is as follows.
For Camera Intent:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1) {
featuredImages_gallery = data.getParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES);
Uri uri = Uri.fromFile(new File(featuredImages_gallery.get(0).getPath()));
Picasso.with(AddPropertiesActivity.this).load(uri).into(img_gallery);
isFeaturedGallery = true;
}
Image Picker from gallery code:
ImagePicker.create(this)
.folderMode(true)
.folderTitle("Folder")
.imageTitle("Tap to select")
.multi()
.limit(5)
.showCamera(false)
.imageDirectory("Camera")
.start(REQUEST_FEATURED_PICKER_GALLERY);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_FEATURED_PICKER_GALLERY) {
if (resultCode == Activity.RESULT_OK && data != null) {
featuredImages_gallery = data.getParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES);
Uri uri = Uri.fromFile(new File(featuredImages_gallery.get(0).getPath()));
Picasso.with(AddPropertiesActivity.this).load(uri).into(img_gallery);
isFeaturedGallery = true;
}
}
}
Uploading data to server:
if (isFeaturedGallery) {
request.addParameter("place_gallery_image[]", featuredImages_gallery);
}
from imagepicker.
Related Issues (20)
- Android 11 - Can't see images from SD Card HOT 3
- Version 1.5.1 - Caused by java.lang.NullPointerException Issue HOT 4
- When I click the OK button after taking a picture in landscape mode, it doesn't go to the next
- Empty Gallery HOT 12
- How to call launcher in java project? HOT 2
- Not working in android 33 HOT 13
- Permission Camera Problems on Android 31 and up HOT 5
- Image model does not include the path variable HOT 1
- uri must not be null HOT 1
- Failed to resolve: com.github.nguyenhoanglam:ImagePicker:1.5.5 HOT 2
- Any Java implementation example? HOT 2
- Not working in Android 9 HOT 3
- Lock camera orientation to portrait mode.
- CAMERA Permission HOT 2
- Is there any way to handle the callback from toolbar back icon HOT 4
- Camera related question HOT 7
- Crashing on Android 13 HOT 3
- [FR] Remove `android:enableOnBackInvokedCallback="true"` config HOT 1
- Android 13 & 14 Crashes + Android 12 HOT 5
- Image Rotation Not Reflected in Image Picker After Rotating Image in Device Gallery
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imagepicker.