How to install the barcode scanning library without a google account?

感情迁移 提交于 2019-12-05 00:46:49

For any google service,you should register your add app at console.

If you don't want to add your app then you can use any third party API for barcode.

https://github.com/zxing/zxing

Rahul Kushwaha

You can use Third Part Library implementation com.journeyapps:zxing-android-embedded:3.5.0

Using this library you can easily integrate QR-Code and BAR Code Reader as well without signing in with a google account.

My code here for Bar-Code Reader:

    package com.example.elanwrap.qr_code_elan;

    import android.content.Intent;
    import android.net.Uri;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    import com.google.zxing.integration.android.IntentIntegrator;
    import com.google.zxing.integration.android.IntentResult;

    import static android.widget.Toast.LENGTH_LONG;

    public class MainActivity extends AppCompatActivity {

        Button button;
        //CREATING OBJECT
        private IntentIntegrator qrCode;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            button = (Button) findViewById(R.id.button);

            qrCode = new IntentIntegrator(this);

            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                   //  start the Scan here
                    qrCode.initiateScan();
                }
            });
        }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            IntentResult intentResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
            super.onActivityResult(requestCode, resultCode, data);
            if (intentResult != null) {
             //passing result to another Activity.
            //    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(intentResult.getContents() + ""));
                Intent browserIntent = new Intent(this, Result_activity.class );
                browserIntent.putExtra("rah",(intentResult.getContents()+""));
                startActivity(browserIntent);



            } else {
                Toast.makeText(getApplicationContext(), " Empty Result ", Toast.LENGTH_SHORT).show();
            }
        }
    }

and:

package com.example.elanwrap.qr_code_elan;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;
import android.widget.Toast;

public class Result_activity extends Activity {
    TextView textView;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result_activity);
        textView=(TextView)findViewById(R.id.details);
        Intent intent = getIntent();
        String str = intent.getStringExtra("rah");
        textView.setText(str);
        Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
    }
}
Lovekesh Kumar

Step 1 : Try including this lib in app based gradle file

Implementation com.google.android.gms:play-services-vision:11.0.2

Implementation info.androidhive:barcode-reader:1.1.2

Step 2 : Create your layout for scanning by taking reference from the link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!