QR Code Scanner Example For Android Students
hi friends i am going to write my new post on Qr scanner. as we all know Qr code is really important
and safe way to transfer data from one device to other. here i am going to tell you how to scan Qr code Tags with android phone
Requirement :
1. Android Studio
2.Android mobile
3.Android SDK
4.mind
So to make it easy we follow these step.
1 . Add dependencies in build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
}
2.XML file for Scanner
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
tools:context="com.rgg.rahulgoswami.qrscanner.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="QR CODE SCANNER AND GENERATOR"
android:id="@+id/textView"
android:textSize="20sp"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Generate QR"
android:id="@+id/button"
android:layout_marginTop="40dp"
android:layout_gravity="center"
android:layout_above="@+id/textView2"
android:layout_alignEnd="@+id/imageView" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Scan QR"
android:id="@+id/button2"
android:layout_marginTop="20dp"
android:layout_gravity="center"
android:layout_alignTop="@+id/button"
android:layout_toStartOf="@+id/button" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="By Perfect RG"
android:id="@+id/textView2"
android:layout_margin="40dp"
android:layout_gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="prfectrg.blogspot.com"
android:id="@+id/textView3"
android:layout_gravity="center_horizontal" />
</LinearLayout>
3. Now Write Java Code In your MainActivity.java
import this class in your activity
import me.dm7.barcodescanner.zxing.ZXingScannerView;
4. Add This code For Scan
mScannerView = new ZXingScannerView(this);
// Programmatically initialize the scanner view
setContentView(mScannerView);
mScannerView.setResultHandler(this);
// Register ourselves as a handler for scan results.
mScannerView.startCamera();
}
@Override public void onPause() {
super.onPause();
mScannerView.stopCamera();
// Stop camera on pause }
@Override public void handleResult(Result result) {
// Do something with the result here
Toast.makeText(MainActivity.this,"This is your Text"+result.getText(),Toast.LENGTH_SHORT);
Log.e("handler", result.getText());
// Prints scan results
Log.e("handler", result.getBarcodeFormat().toString());
// Prints the scan format (qrcode)
}
Complete Code
package com.rgg.rahulgoswami.qrscanner;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.zxing.Result;
import me.dm7.barcodescanner.zxing.ZXingScannerView;
public class MainActivity extends AppCompatActivity implements
View.OnClickListener, ZXingScannerView.ResultHandler {
private ZXingScannerView mScannerView;
Button scancode,generatecode;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scancode=(Button)findViewById(R.id.button2);
generatecode=(Button)findViewById(R.id.button);
mScannerView = new ZXingScannerView(MainActivity.this);
generatecode.setOnClickListener(this);
scancode.setOnClickListener(this);
}
@Override public void onClick(View v) {
if (v==generatecode)
{
Intent i=new Intent(MainActivity.this,QRCodeActivity.class);
startActivity(i);
}
if(v==scancode)
{
ScanCode();
}
}
private void ScanCode() {
mScannerView = new ZXingScannerView(this);
// Programmatically initialize the scanner view
setContentView(mScannerView);
mScannerView.setResultHandler(this);
// Register ourselves as a handler for scan results.
mScannerView.startCamera();
}
@Override public void onPause() {
super.onPause();
mScannerView.stopCamera();
// Stop camera on pause }
@Override public void handleResult(Result result) {
// Do something with the result here
Toast.makeText(MainActivity.this,"This is your Text"+result.getText(),Toast.LENGTH_SHORT);
Log.e("handler", result.getText());
// Prints scan results Log.e("handler", result.getBarcodeFormat().toString());
// Prints the scan format (qrcode)
}
}
in Mainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rgg.rahulgoswami.qrscanner">
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".QRCodeActivity"></activity>
</application>
</manifest>
and safe way to transfer data from one device to other. here i am going to tell you how to scan Qr code Tags with android phone
Requirement :
1. Android Studio
2.Android mobile
3.Android SDK
4.mind
So to make it easy we follow these step.
1 . Add dependencies in build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
}
2.XML file for Scanner
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
tools:context="com.rgg.rahulgoswami.qrscanner.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="QR CODE SCANNER AND GENERATOR"
android:id="@+id/textView"
android:textSize="20sp"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Generate QR"
android:id="@+id/button"
android:layout_marginTop="40dp"
android:layout_gravity="center"
android:layout_above="@+id/textView2"
android:layout_alignEnd="@+id/imageView" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Scan QR"
android:id="@+id/button2"
android:layout_marginTop="20dp"
android:layout_gravity="center"
android:layout_alignTop="@+id/button"
android:layout_toStartOf="@+id/button" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="By Perfect RG"
android:id="@+id/textView2"
android:layout_margin="40dp"
android:layout_gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="prfectrg.blogspot.com"
android:id="@+id/textView3"
android:layout_gravity="center_horizontal" />
</LinearLayout>
3. Now Write Java Code In your MainActivity.java
import this class in your activity
import me.dm7.barcodescanner.zxing.ZXingScannerView;
4. Add This code For Scan
mScannerView = new ZXingScannerView(this);
// Programmatically initialize the scanner view
setContentView(mScannerView);
mScannerView.setResultHandler(this);
// Register ourselves as a handler for scan results.
mScannerView.startCamera();
}
@Override public void onPause() {
super.onPause();
mScannerView.stopCamera();
// Stop camera on pause }
@Override public void handleResult(Result result) {
// Do something with the result here
Toast.makeText(MainActivity.this,"This is your Text"+result.getText(),Toast.LENGTH_SHORT);
Log.e("handler", result.getText());
// Prints scan results
Log.e("handler", result.getBarcodeFormat().toString());
// Prints the scan format (qrcode)
}
Complete Code
package com.rgg.rahulgoswami.qrscanner;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.zxing.Result;
import me.dm7.barcodescanner.zxing.ZXingScannerView;
public class MainActivity extends AppCompatActivity implements
View.OnClickListener, ZXingScannerView.ResultHandler {
private ZXingScannerView mScannerView;
Button scancode,generatecode;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scancode=(Button)findViewById(R.id.button2);
generatecode=(Button)findViewById(R.id.button);
mScannerView = new ZXingScannerView(MainActivity.this);
generatecode.setOnClickListener(this);
scancode.setOnClickListener(this);
}
@Override public void onClick(View v) {
if (v==generatecode)
{
Intent i=new Intent(MainActivity.this,QRCodeActivity.class);
startActivity(i);
}
if(v==scancode)
{
ScanCode();
}
}
private void ScanCode() {
mScannerView = new ZXingScannerView(this);
// Programmatically initialize the scanner view
setContentView(mScannerView);
mScannerView.setResultHandler(this);
// Register ourselves as a handler for scan results.
mScannerView.startCamera();
}
@Override public void onPause() {
super.onPause();
mScannerView.stopCamera();
// Stop camera on pause }
@Override public void handleResult(Result result) {
// Do something with the result here
Toast.makeText(MainActivity.this,"This is your Text"+result.getText(),Toast.LENGTH_SHORT);
Log.e("handler", result.getText());
// Prints scan results Log.e("handler", result.getBarcodeFormat().toString());
// Prints the scan format (qrcode)
}
}
in Mainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rgg.rahulgoswami.qrscanner">
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".QRCodeActivity"></activity>
</application>
</manifest>
QR Code Scanner Example For Android Students
Reviewed by Unknown
on
8:58 PM
Rating:
QR Scanner 2018 for android is the fastest barcode scanner and qr code reader.
ReplyDeleteQR Code & Barcode Scanner is the best and fastest QR code/ bar code creator & scanner app free for Android. By using the phone's camera, this qr scanner will automatically scan qr code and recognize the information of QR code or bar code. And supports all major barcode and QR code formats.
Features
• QR code Reader.
• Barcode Scanner.
• QR Scanner.
• Flashlight supported for low-light environments.
• Wifi QR code supported , auto connect to Wifi hotspot without password.
• Create QR code and could save to Gallery/Album
• Scan history saved
• qr scanner
• Simple & easy to Use
It's not only a QR code scanner, but also a QR code generator/QR generator.
It can read all types including text, url, product, contact, ISBN, calendar, email, location, Wi-Fi and many other formats.
After scan and automatic decoding, user is provided with only the relevant options for individual type and can take appropriate action.
QR Code & Barcode Scanner is the best QR code scanner / QR scanner / QR reader / barcode scanner / barcode reader!
Free barcode scanner app!
Download free qr scanner - qr code reader and barcode scanner app and enjoy!
https://play.google.com/store/apps/details?id=com.hrmtech.qrcodereaderbarcodescanner
This is an article about scanning Qrcode. It's very good. It would be better if you could scan the Qrcode on the pdf.
ReplyDeletenice blog , you can also check this blog for php,js , html, css, android tutorials https://thecoderain.blogspot.com
ReplyDeleteI read your blog frequently and I just thought I’d say keep up the amazing work!
ReplyDeleteqr code generator online
You have done a great job I appreciate your effort and I hope you will get more positive comments from the web users.
ReplyDeleteAsset Management Software
Asset Tracking Software
IT Asset Management Software
Fixed Asset Management Software
nice
ReplyDeleteThis post is to help marketers reach more audience using QR codes. Learn how to create your own, and how you can augment the chance of consumers scanning them. These are the 4 quick steps to creating your QR code and a start to reaching more audience.QR Code Creator
ReplyDeleteits good to see your blog post related to the QR code scanner and you have written valuable and helpful information..keep updating with new stuff related to the barcode printer and ID Card Printer
ReplyDeleteI recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. best photo scanner
ReplyDeleteQR Code & Barcode Scanner is the best and fastest QR code/ bar code creator & scanner app free for Android. By using the phone's camera, this qr scanner will automatically scan qr code and recognize the information of QR code or bar code. And supports all major barcode and QR code formats.
ReplyDeleteFeatures
• QR code Reader.
• Barcode Scanner.
• QR Scanner.
• Flashlight supported for low-light environments.
• Wifi QR code supported , auto connect to Wifi hotspot without password.
• Create QR code and could save to Gallery/Album
• Scan history saved
• qr scanner
• Simple & easy to Use
It's not only a QR code scanner, but also a QR code generator/QR generator.
It can read all types including text, url, product, contact, ISBN, calendar, email, location, Wi-Fi and many other formats.
After scan and automatic decoding, user is provided with only the relevant options for individual type and can take appropriate action.
QR Code & Barcode Scanner is the best QR code scanner / QR scanner / QR reader / barcode scanner / barcode reader!
Free barcode scanner app!
Download Now Free https://play.google.com/store/apps/details?id=qrcodescanner.barcodescanner.barcodereader.qrcodereader