Comments (8)
@Drjacky Update below function in IntentUtils this class:-
https://github.com/Drjacky/ImagePicker/blob/master/imagepicker/src/main/kotlin/com/github/drjacky/imagepicker/util/IntentUtils.kt
This is working for me
/**
* @return Intent Camera Intent
*/
@JvmStatic
fun getCameraIntent(uri: Uri, tryFrontCamera: Boolean): Intent {
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
if (tryFrontCamera) when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> {
intent.putExtra(CAMERA_FACING_EXTRA, CameraCharacteristics.LENS_FACING_FRONT) // Tested on API 27 Android version 8.0(Nexus 6P)
intent.putExtra("android.intent.extra.USE_FRONT_CAMERA", true)// tested on android 11
intent.putExtra("android.intent.extras.CAMERA_FACING", CameraCharacteristics.LENS_FACING_FRONT)// tested on android 11
intent.putExtra("android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);// tested on android 11
}
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 && Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> {
intent.putExtra(
CAMERA_FACING_EXTRA,
CameraCharacteristics.LENS_FACING_FRONT
) // Tested on API 24 Android version 7.0(Samsung S6)
}
Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1 -> intent.putExtra(
CAMERA_FACING_EXTRA,
1
) // Tested API 21 Android version 5.0.1(Samsung S4)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri)
} else {
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri)
}
return intent
}
from imagepicker.
Thanks to @ArisChoice, https://github.com/Drjacky/ImagePicker/releases/tag/2.1.15
P.S Some devices still don't support defining front camera as default - Like OnePlus
from imagepicker.
@Drjacky would you recommend I copy those Intent extras to use this, or somehow try to set tryFrontCamera
by intercepting the provider? Not sure what the ideal usage would be. Also thanks @ArisChoice for the update!
from imagepicker.
I am Looking for same feature.
from imagepicker.
@ArisChoice Could you please create a pull request and I'll check and if it works, I'll merge it to the codebase. Thanks!
from imagepicker.
@shobhik Pass true
to tryFrontCamera
parameter in getCameraIntent
from imagepicker.
where do I call this function please give me an example. I am trying to open the front camera at first.
from imagepicker.
@Ahsan2408
https://github.com/Drjacky/ImagePicker/blob/54e52258fed1d3f7765a8382b4415c0e1912c79d/imagepicker/src/main/kotlin/com/github/drjacky/imagepicker/constant/ImageProvider.kt
ImagePicker.with(this)
//...
.provider(ImageProvider.BOTH) //Or bothCameraGallery()
.createIntentFromDialog { launcher.launch(it) }
from imagepicker.
Related Issues (20)
- Black Image returned when cropping large images with higher resolution especially raw camera photos, tried it with a (3456 * 4608) . It doesn't crash though. HOT 6
- Setting up different languages HOT 1
- Android 13 not workinf HOT 4
- WRITE_EXTERNAL_STORAGE is denied between Sdk 29 and 33. HOT 2
- Getting ANR in some devices when picking from Gallery.
- [Crash] CropProvider.convertBitmapToFile - java.io.IOException - No such file or directory HOT 2
- Image provider can not be null
- In AndroidManifast file, Kindly updated the <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />, like android:maxSdkVersion="33" this permission not working in android 10, 11, 12 devices
- Delete image when succesfull
- Screen Orientation Issue: Image Picker HOT 4
- Java Sample HOT 1
- API 29 crop image preview not showing black screen only available after crop HOT 1
- set limit on multiple images
- app crash when launch HOT 1
- Cropped Aspect Ratio! HOT 1
- Manifest merger failed : Attribute activity#com.yalantis.ucrop.UCropActivity@theme value=(@style/CameraTheme) from [paysprint_onboarding_live_1_0_9.aar] AndroidManifest.xml:56:13-47
- Could not scale to target size HOT 1
- Open front camera at first.
- [Crash] When picking a camera image without setting crop() HOT 1
- return error "Image provider can not be null"? Any idea...
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.