I started using Camera
from Expo for React Native ( https://docs.expo.io/versions/v35.0.0/sdk/camera/ )
I see camera window but when I call await this.camera.takePictureAsync();
the Promise is never finished and I get no output.
My camera:
<Camera ref={(camera) => this.camera = camera}
style={{flex: 1}}
type={this.state.type}
>
<Button onPress={() => this.snap()} title='SNAP'/>
</Camera>
Snap function:
snap = async () => {
if (this.camera) {
console.log("SNAP!");
let photo = await this.camera.takePictureAsync();
console.log(photo);
}
};
The SNAP!
is shown in console so there is no problem with camera itself. Second console.log
is never called.
I am testing my app on Android 9 (Real device)
EDIT: It is working on emulator, so there must be problem specifically with the real device
Try to set useCamera2Api prop to true for Camera element.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.