:white_square_button: [Android 库] 使用 Google 的移动视觉 API 读取 QR 码,但无需麻烦
:white_square_button: [Android 库] 使用 Google 的移动视觉 API 读取 QR 码,但无需麻烦
Android library which makes use of Google's Mobile Vision API to enable reading QR Code.
The library is built for simplicity and ease of use. It not only eliminates most boilerplate code for dealing with setting up QR Code reading , but also provides an easy and simple API to retrieve information from QR Code quickly.
Requires Google Play Services
Starting with 1.0.4, Changes exist in the releases tab.
#Integration QREader is available in the Jcenter, so getting it as simple as adding it as a dependency
SurfaceView and QREader in onCreate()// QREader
private SurfaceView mySurfaceView;
private QREader qrEader;
..
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
..
..
// Setup SurfaceView
// -----------------
mySurfaceView = (SurfaceView) findViewById(R.id.camera_view);
// Init QREader
// ------------
qrEader = new QREader.Builder(this, mySurfaceView, new QRDataListener() {
@Override
public void onDetected(final String data) {
Log.d("QREader", "Value : " + data);
text.post(new Runnable() {
@Override
public void run() {
text.setText(data);
}
});
}
}).facing(QREader.BACK_CAM)
.enableAutofocus(true)
.height(mySurfaceView.getHeight())
.width(mySurfaceView.getWidth())
.build();
}onResume() @Override
protected void onResume() {
super.onResume();
// Init and Start with SurfaceView
// -------------------------------
qrEader.initAndStart(mySurfaceView);
}onPause() @Override
protected void onPause() {
super.onPause();
// Cleanup in onPause()
// --------------------
qrEader.releaseAndCleanup();
}To check if the camera is running
boolean isCameraRunning = qrEader.isCameraRunning()To stop QREader
qrEader.stop();To start QREader
qrEader.start();Check the included sample app for a working example.
I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:
develop branch. Any other branch (unless specified by the maintainers) will get rejected.If you found this library helpful or you learned something from the source code and want to thank me, consider buying me a cup of :coffee:
- PayPal
- Bitcoin Address: 13PjuJcfVW2Ad81fawqwLtku4bZLv1AxCL
暂无开放 Issues,或尚未同步最近议题。