journeyapps / zxing-android-embedded

Barcode scanner library for Android, based on the ZXing decoder
https://journeyapps.com/
Apache License 2.0
5.68k stars 1.26k forks source link

Camera Scanning in Portrait Mode #640

Closed karan2vel closed 3 years ago

karan2vel commented 3 years ago

Description of the problem:

How to make the scanning in portrait mode in IntentIntegrator ? I have tried the comments answers mentioned in the existing closed issues but still it didn't worked. Below is my gradle file content.

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.0"
    defaultConfig {
        applicationId "com.thales.qrcodesample"
        minSdkVersion 28
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.journeyapps:zxing-android-embedded:4.2.0'
    implementation "com.google.zxing:core:3.3.3"
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Activity code:

IntentIntegrator integrator = new IntentIntegrator(MainActivity.this);            
integrator.setOrientationLocked(false);          //Also tried with true
integrator.initiateScan();

Manifest code :

  <activity android:name=".MainActivity"
            android:screenOrientation="fullSensor"
            tools:replace="screenOrientation"
            android:stateNotNeeded="true"
            android:windowSoftInputMode="stateAlwaysHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

Correct me if any thing is wrong here.