journeyapps/zxing-android-embedded — 5.9k★ trên GitHub (Java). Barcode scanner library for Android, based on the ZXing decoder
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
This option does not require changing library versions, but may complicate the build process.
This requires Android Gradle Plugin version 4.0.0 or later.
See Java 8+ API desugaring support.
Example for SDK 21+:
android {
defaultConfig {
minSdkVersion 21
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}
SDK 19+ additionally requires multiDex. In addition to these gradle config changes, the Application
class must also be changed. See for details: Configure your app for multidex.
android {
defaultConfig {
multiDexEnabled true
minSdkVersion 19
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
implementation "androidx.multidex:multidex:2.0.1"
}
Hardware Acceleration
Hardware acceleration is required since TextureView is used.
Note: startActivityForResult is deprecated, so this example uses registerForActivityResult instead.
See for details: https://developer.android.com/training/basics/intents/result
startActivityForResult can still be used via IntentIntegrator, but that is not recommended anymore.
// Register the launcher and result handler
private final ActivityResultLauncher<ScanOptions> barcodeLauncher = registerForActivityResult(new ScanContract(),
result -> {
if(result.getContents() == null) {
Toast.makeText(MyActivity.this, "Cancelled", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MyActivity.this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
}
});
// Launch
public void onButtonClick(View view) {
barcodeLauncher.launch(new ScanOptions());
}
Customize options:
ScanOptions options = new ScanOptions();
options.setDesiredBarcodeFormats(ScanOptions.ONE_D_CODE_TYPES);
options.setPrompt("Scan a barcode");
options.setCameraId(0); // Use a specific camera of the device
options.setBeepEnabled(false);
options.setBarcodeImageEnabled(true);
barcodeLauncher.launch(options);
See BarcodeOptions for more options.
Generate Barcode example
While this is not the primary purpose of this library, it does include basic support for
generating some barcode types:
To customize the generated barcode image, use the setBackgroundColor and setForegroundColor functions of the
BarcodeEncoder class with a @ColorInt
value to update the background and foreground colors of the barcode respectively. By default, the barcode has a
white background and black foreground.
Changing the orientation
To change the orientation, specify the orientation in your AndroidManifest.xml and let the ManifestMerger to update the Activity's definition.
ScanOptions options = new ScanOptions();
options.setOrientationLocked(false);
barcodeLauncher.launch(options);
Customization and advanced options
See EMBEDDING.
For more advanced options, look at the Sample Application,
and browse the source code of the library.
This is considered advanced usage, and is not well-documented or supported.
Android Permissions
The camera permission is required for barcode scanning to function. It is automatically included as
part of the library. On Android 6 it is requested at runtime when the barcode scanner is first opened.
When using BarcodeView directly (instead of via IntentIntegrator / CaptureActivity), you have to
request the permission manually before calling BarcodeView#resume(), otherwise the camera will
fail to open.
Building locally
./gradlew assemble
To deploy the artifacts the your local Maven repository:
./gradlew publishToMavenLocal
You can then use your local version by specifying in your build.gradle file:
repositories {
mavenLocal()
}
Sponsored by
JourneyApps
License
Licensed under the Apache License 2.0
Copyright (C) 2012-2022 ZXing authors, Journey Mobile
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
journeyapps/zxing-android-embedded có bao nhiêu sao?
journeyapps/zxing-android-embedded có 5.9k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/journeyapps/zxing-android-embedded. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
journeyapps/zxing-android-embedded có những chủ đề gì?
GitHub topics của journeyapps/zxing-android-embedded: "android-library", "barcode-scanning", "zxing-android". TopGit xếp repo vào nhóm mã nguồn mở.
journeyapps/zxing-android-embedded còn đang phát triển không?
Commit gần nhất trên journeyapps/zxing-android-embedded là 2.3 năm trước (theo timestamp GitHub). Repo có 1.3k fork — một chỉ báo về mức độ quan tâm của cộng đồng.
journeyapps/zxing-android-embedded là gì?
journeyapps/zxing-android-embedded (journeyapps/zxing-android-embedded) là dự án Java trên GitHub. Theo mô tả gốc: Barcode scanner library for Android, based on the ZXing decoder
journeyapps/zxing-android-embedded viết bằng ngôn ngữ gì?
journeyapps/zxing-android-embedded chủ yếu viết bằng Java. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về zxing-android-embedded?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về zxing-android-embedded.