Zxing二维码生成和扫描
step1: D:\workspace\ZxingDemo\app\build.gradle
implementation 'com.journeyapps:zxing-android-embedded:4.2.0'
implementation 'com.google.code.gson:gson:2.8.0'
step2: D:\workspace\ZxingDemo\app\src\main\AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA"/>
step3: D:\workspace\ZxingDemo\app\src\main\res\layout\activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bt_scan"
android:text="Scan"
android:layout_centerInParent="true"/>
</RelativeLayout>
step4: D:\workspace\ZxingDemo\app\src\main\res\layout\activity_qr_code.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/qrcode_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TextView
android:id="@+id/ad_tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/ad_iv_qrcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/ad_tv_title"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</RelativeLayout>
step5: D:\workspace\ZxingDemo\app\src\main\java\com\example\zxingdemo\ScanBean.java
package com.example.zxingdemo;
public class ScanBean {
/**
* age : 26
* email : 249175190@qq.com
* isDeveloper : true
* name : Normal
*/
private int age;
private String email;
private boolean isDeveloper;
private String name;
public int getAge() {
return age;
}
public