private fun startCameraSource() { val code: Int = GoogleApiAvailability.getInstance() .isGooglePlayServicesAvailable(ApplicationProvider.getApplicationContext()) if (code != ConnectionResult.SUCCESS) { val dlg: Dialog = GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS) dlg.show() } if (mCameraSource != null) { try { mPreview.start(mCameraSource, mGraphicOverlay) } catch (e: IOException) { Log.e(TAG, "Unable to start camera source.", e) mCameraSource.release() mCameraSource = null } } }
Starts or restarts the camera source , if it exists . If the camera source does n't exist yet ( e.g. , because onResume was called before the camera source was created ) , this will be called again when the camera source is created .