ZXingを使用する際にデフォルトだと横方向になってしまうのを縦方向に表示するようにした自分メモです。
結論
CaptureActivity を継承した、空の Activity 作成し、 IntentIntegrator の captureActivity に渡してあげる。
// 空の Activity を作成
private class PortraitActivity : CaptureActivity()
// 自分の場合は Fragment 内で使用していたので、forSupportFragment(this) としてあげています。
val integrator = IntentIntegrator.forSupportFragment(this).apply {
setPrompt("QRを読み込んでください")
captureActivity = PortraitActivity::class.java // ここで渡してあげる
}
integrator.initiateScan()
とりあえず、これだけ行えばバーコードリーダーを開いた際に縦画面になります。
最後に
今は ZXing は initateScan() ですぐに読み取りが行えるのですが、情報が英語の方が多い気がしています。。
今後はドキュメントの豊富な Firebase の方に移行するかもです。
移行した時はまた記事を書きたいと思います。
見ていただきありがとうございます。