Click here to Skip to main content
14,364,335 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am developing a simple project, that QR code scanning is an alternative option for login.

I'm trying to use Zxing I tried almost all of the tutorials on youtube but I can't find my answer.

What I want is when I scan a QR code I can paste the result on my editTextUser and editTextPass.

Thank you so much for your help I don't know where to ask so I hope you can help I really appreciate your help.

What I have tried:

package com.logizard.logizard_go.Activities;

import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;


import com.logizard.logizard_go.Common.LoginManager;
import com.logizard.logizard_go.R;
import com.logizard.logizard_go.models.ResponseDataForCommon;

public class Login extends AppCompatActivity {//implements ZXingScannerView.ResultHandler
    private TextView labelErrorMessage;
    private EditText editTextUser;
    private EditText editTextPass;
    private Button buttonLogin;
    private ImageButton imageButton2;

    static final int GET_SCANNED = 1;

    protected void onCreate(Bundle savedInstanceState) {

        labelErrorMessage = findViewById(;
        editTextUser = findViewById(;
        editTextPass = findViewById(;

        buttonLogin = (Button) findViewById(;
        buttonLogin.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                String userId = editTextUser.getText().toString().trim();
                String password = editTextPass.getText().toString().trim();

                if (userId.isEmpty()){
                    editTextUser.setError("User_ID is empty.");

                if (password.isEmpty()){
                    editTextPass.setError("Password is empty.");
                LoginTask task = new LoginTask();
                task.execute(userId, password);
        imageButton2 = (ImageButton) findViewById(;

        imageButton2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = new Intent(Login.this, ScanResult.class);


    private class LoginTask extends AsyncTask<String, String, String> {
        protected String doInBackground(String... strings) {
            // The first, the app try to do login with "PROCESS_FLG"'s value is "1"(the meaning is trying as the user is registered).
            LoginManager.login(strings[0], strings[1], "1", (ResponseDataForCommon data) -> {
                // The scene of this app is moved to the main menu.
                Intent intent = new Intent(Login.this, MainMenu.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            }, (Integer errorCode) -> {
                labelErrorMessage.setText("Couldn't find your Logizard Zero account.");
            }, (String message) -> {
            return null;

Richard MacCutchan 7-Nov-19 4:04am
You need to explain what the actual problem is.
David Crow 7-Nov-19 9:14am
I do not see that you are using any ZXing components.

Regarding your "when I scan a QR code I can paste the result on my editTextUser and editTextPass" comment, I see where you are reading values from the editTextUser and editTextPass controls and passing them to LoginManager.login(), but that's it. Shouldn't you be at least using an ZXingScannerView object?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100