Reputation: 742
In Nativescript using ML-kit text recognition for devices with sdk less than 23 when I pause the app and resume it brokes with an error:
System.err: Caused by: java.lang.RuntimeException: Camera initialization failed because the camera device was already opened(-16)
In sdk >= 23 it seems that it works fine, but the idea is to make that it works in all devices (my client device has android 5.5 so sdk < 23). I'm using the plugin on real time:
<FirebaseMLKitTextRecognition:MLKitTextRecognition
id="ocrCam"
class="ocrCam"
width="100%"
height="50%"
processEveryNthFrame="3"
preferFrontCamera="false"
torchOn="{{ lightOn }}"
pause="{{ pauseOCR }}"
scanResult="onTextRecognitionResult" />
I read something about permissions like older versions no need them but new ones need them and it crashes when ask for them. But the issue where closed by "min sdk 23".
Are there any method to controll that crash or destroying the xml element on pause?
Upvotes: 1
Views: 307
Reputation: 21908
Try releasing the camera on pause event of your application / activity.
// Where ocrCam should be reference to MLKitTextRecognition
ocrCam.camera.release();
Upvotes: 1