QR Code Scanner App in Android Studio - With Free Source Code

QR Code Scanner App in Android Studio - With Free Source Code



Let's get started with QR Code Scanner App in Android Studio. Also, I am going to give you the Source code of this QR Code Scanner.

I will build this QR Code Scanner App with the help of the Github Library the Name is Code Scanner:

In this library, we have the features like this:
  • Enable Portrait and Landscape orientation
  • With Auto Focus and Flash control
  • And with the Front and Back Camera
  • This is also customizable and Kotlin Friendly
  • Also, Able us to Touch to focus.
So, without wasting the time let's begin,


First Add this Dependency to your build.gradle (app level module)

            dependencies {
                    implementation 'com.budiyev.android:code-scanner:2.1.0'
            }

And then add the Camera permission in the AndroidManifest File.

<uses-permission android:name="android.permission.CAMERA"/>

And After copy the Code in Dashboard Activity:

<com.budiyev.android.codescanner.CodeScannerView
        android:id="@+id/scanner_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:autoFocusButtonColor="@android:color/white"
        app:autoFocusButtonVisible="true"
        app:flashButtonColor="@android:color/white"
        app:flashButtonVisible="true"
        app:frameColor="@android:color/white"
        app:frameCornersSize="50dp"
        app:frameCornersRadius="0dp"
        app:frameAspectRatioWidth="1"
        app:frameAspectRatioHeight="1"
        app:frameSize="0.75"
        app:frameThickness="2dp"
        app:maskColor="#77000000"/>

And Next Code is in DashboardActivity.java

public class DashboardActivty.java extends AppCompatActivity {
    private CodeScanner mCodeScanner;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dashboard);
        CodeScannerView scannerView = findViewById(R.id.scanner_view);
        mCodeScanner = new CodeScanner(this, scannerView);
        mCodeScanner.setDecodeCallback(new DecodeCallback() {
            @Override
            public void onDecoded(@NonNull final Result result) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(MainActivity.this, result.getText(), Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });
        scannerView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mCodeScanner.startPreview();
            }
        });       
    }

    @Override
    protected void onResume() {
        super.onResume();
        mCodeScanner.startPreview();
    }

    @Override
    protected void onPause() {
        mCodeScanner.releaseResources();
        super.onPause();
    }
}

And next, we have the Following Features in QR Code Scanner. This will be the Complete Android App Development Series in which you will learn How to Add the Splash Screen With Animations, OnBoardingScreen with Animation in Android Studio, QR Code Scanner, QR Code Generator, Sharing the QR Code, Internet Checking, Exit Confirmation, Google Analytics, Notification, Performance Checking, and In-App Messaging.

Read the Next Post or Subscribe to our YouTube Channel Android Tutorials to get the latest updates

Check out this #AndroidTutorialsPlaylist

(1) How To Convert A Website Into a Professional Android App Using ANDROID STUDIO  2020 - https://www.youtube.com/playlist?list=PL7nYsbTdViSqf_RlSZvdMshSxCdeE7Dl6 

(2) Wallpaper App in Android Studio (using Pixel API) | Android Tutorials - https://www.youtube.com/playlist?list=PL7nYsbTdViSowlrgM6rDQJrIL7lL2ansh 



Subscribe Here

#AndroidTutorials  #QRCodeApp

Post a Comment

Previous Post Next Post