バーコード スキャナー アプリにカメラを使用しており、一部のデバイス (LG G Flex、Asus Nexus 7) で Android ランタイム例外 - カメラ サービスに接続できませんでした。以下のメニフェストファイルのスニペットは次のとおりです。
`uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
uses-permission android:name="android.permission.CAMERA"
....`
一時停止、停止、および破棄時にカメラを解放しています。
/**
* Restarts the camera.
*/
@Override
protected void onResume() {
super.onResume();
try {
startCameraSource();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Stops the camera.
*/
@Override
protected void onPause() {
super.onPause();
if (mPreview != null) {
mPreview.stop();
}
}
/**
* Releases the resources associated with the camera source, the associated detectors, and the
* rest of the processing pipeline.
*/
@Override
protected void onDestroy() {
super.onDestroy();
if (mPreview != null) {
mPreview.release();
}
}
まだランタイム例外を超えていますが、再現できるように2つ以上のデバイスがありません。その問題の解決策はありますか?