{"id":13848318,"url":"https://github.com/journeyapps/zxing-android-embedded","last_synced_at":"2025-05-13T18:11:12.032Z","repository":{"id":5695000,"uuid":"6905493","full_name":"journeyapps/zxing-android-embedded","owner":"journeyapps","description":"Barcode scanner library for Android, based on the ZXing decoder","archived":false,"fork":false,"pushed_at":"2024-08-04T04:24:21.000Z","size":8388,"stargazers_count":5849,"open_issues_count":118,"forks_count":1285,"subscribers_count":168,"default_branch":"master","last_synced_at":"2025-04-25T15:48:35.577Z","etag":null,"topics":["android-library","barcode-scanning","zxing-android"],"latest_commit_sha":null,"homepage":"https://journeyapps.com/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/journeyapps.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-11-28T16:36:39.000Z","updated_at":"2025-04-25T08:41:59.000Z","dependencies_parsed_at":"2022-07-21T04:38:42.778Z","dependency_job_id":"b2e01adf-dcbb-4b07-a1b0-f08a01f81f10","html_url":"https://github.com/journeyapps/zxing-android-embedded","commit_stats":{"total_commits":1203,"total_committers":60,"mean_commits":20.05,"dds":0.5303408146300914,"last_synced_commit":"d09b7c76c3124fbfbd096a65d60b1997f37ff90f"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/journeyapps%2Fzxing-android-embedded","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/journeyapps%2Fzxing-android-embedded/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/journeyapps%2Fzxing-android-embedded/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/journeyapps%2Fzxing-android-embedded/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/journeyapps","download_url":"https://codeload.github.com/journeyapps/zxing-android-embedded/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254000854,"owners_count":21997442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-library","barcode-scanning","zxing-android"],"created_at":"2024-08-04T19:00:46.868Z","updated_at":"2025-05-13T18:11:11.974Z","avatar_url":"https://github.com/journeyapps.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# ZXing Android Embedded\n\nBarcode scanning library for Android, using [ZXing][2] for decoding.\n\nThe project is loosely based on the [ZXing Android Barcode Scanner application][2], but is not affiliated with the official ZXing project.\n\nFeatures:\n\n1. Can be used via Intents (little code required).\n2. Can be embedded in an Activity, for advanced customization of UI and logic.\n3. Scanning can be performed in landscape or portrait mode.\n4. Camera is managed in a background thread, for fast startup time.\n\nA sample application is available in [Releases](https://github.com/journeyapps/zxing-android-embedded/releases).\n\nBy default, Android SDK 24+ is required because of `zxing:core` 3.4.x.\nSDK 19+ is supported with additional configuration, see [Older SDK versions](#older-sdk-versions).\n\n## Adding aar dependency with Gradle\n\nAdd the following to your `build.gradle` file:\n\n```groovy\n// Config for SDK 24+\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation 'com.journeyapps:zxing-android-embedded:4.3.0'\n}\n```\n\n## Older SDK versions\n\nBy default, only SDK 24+ will work, even though the library specifies 19 as the minimum version.\n\nFor SDK versions 19+, one of the changes below are required.\nSome older SDK versions below 19 may work, but this is not tested or supported.\n\n### Option 1. Downgrade zxing:core to 3.3.0\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false }\n    implementation 'com.google.zxing:core:3.3.0'\n}\n```\n\n### Option 2: Desugaring (Advanced)\n\nThis option does not require changing library versions, but may complicate the build process.\n\nThis requires Android Gradle Plugin version 4.0.0 or later.\n\nSee [Java 8+ API desugaring support](https://developer.android.com/studio/write/java8-support#library-desugaring).\n\nExample for SDK 21+:\n\n```groovy\nandroid {\n    defaultConfig {\n        minSdkVersion 21\n    }\n\n    compileOptions {\n        // Flag to enable support for the new language APIs\n        coreLibraryDesugaringEnabled true\n        // Sets Java compatibility to Java 8\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n}\n\ndependencies {\n    implementation 'com.journeyapps:zxing-android-embedded:4.3.0'\n\n    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'\n}\n```\n\nSDK 19+ additionally requires multiDex. In addition to these gradle config changes, the Application\nclass must also be changed. See for details: [Configure your app for multidex](https://developer.android.com/studio/build/multidex#mdex-gradle).\n\n```groovy\nandroid {\n    defaultConfig {\n        multiDexEnabled true\n        minSdkVersion 19\n    }\n\n    compileOptions {\n        // Flag to enable support for the new language APIs\n        coreLibraryDesugaringEnabled true\n        // Sets Java compatibility to Java 8\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n}\n\ndependencies {\n    implementation 'com.journeyapps:zxing-android-embedded:4.3.0'\n\n    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'\n    implementation \"androidx.multidex:multidex:2.0.1\"\n}\n```\n\n## Hardware Acceleration\n\nHardware acceleration is required since TextureView is used.\n\nMake sure it is enabled in your manifest file:\n\n```xml\n    \u003capplication android:hardwareAccelerated=\"true\" ... \u003e\n```\n\n## Usage with ScanContract\n\nNote: `startActivityForResult` is deprecated, so this example uses `registerForActivityResult` instead.\nSee for details: https://developer.android.com/training/basics/intents/result\n\n`startActivityForResult` can still be used via `IntentIntegrator`, but that is not recommended anymore.\n\n```java\n// Register the launcher and result handler\nprivate final ActivityResultLauncher\u003cScanOptions\u003e barcodeLauncher = registerForActivityResult(new ScanContract(),\n        result -\u003e {\n            if(result.getContents() == null) {\n                Toast.makeText(MyActivity.this, \"Cancelled\", Toast.LENGTH_LONG).show();\n            } else {\n                Toast.makeText(MyActivity.this, \"Scanned: \" + result.getContents(), Toast.LENGTH_LONG).show();\n            }\n        });\n\n// Launch\npublic void onButtonClick(View view) {\n    barcodeLauncher.launch(new ScanOptions());\n}\n```\n\nCustomize options:\n```java\nScanOptions options = new ScanOptions();\noptions.setDesiredBarcodeFormats(ScanOptions.ONE_D_CODE_TYPES);\noptions.setPrompt(\"Scan a barcode\");\noptions.setCameraId(0);  // Use a specific camera of the device\noptions.setBeepEnabled(false);\noptions.setBarcodeImageEnabled(true);\nbarcodeLauncher.launch(options);\n```\n\nSee [BarcodeOptions][5] for more options.\n\n### Generate Barcode example\n\nWhile this is not the primary purpose of this library, it does include basic support for\ngenerating some barcode types:\n\n```java\ntry {\n  BarcodeEncoder barcodeEncoder = new BarcodeEncoder();\n  Bitmap bitmap = barcodeEncoder.encodeBitmap(\"content\", BarcodeFormat.QR_CODE, 400, 400);\n  ImageView imageViewQrCode = (ImageView) findViewById(R.id.qrCode);\n  imageViewQrCode.setImageBitmap(bitmap);\n} catch(Exception e) {\n\n}\n```\n\nTo customize the generated barcode image, use the `setBackgroundColor` and `setForegroundColor` functions of the\n`BarcodeEncoder` class with a [`@ColorInt`](https://developer.android.com/reference/androidx/annotation/ColorInt)\nvalue to update the background and foreground colors of the barcode respectively. By default, the barcode has a\nwhite background and black foreground.\n\n\n### Changing the orientation\n\nTo change the orientation, specify the orientation in your `AndroidManifest.xml` and let the `ManifestMerger` to update the Activity's definition.\n\nSample:\n\n```xml\n\u003cactivity\n\t\tandroid:name=\"com.journeyapps.barcodescanner.CaptureActivity\"\n\t\tandroid:screenOrientation=\"fullSensor\"\n\t\ttools:replace=\"screenOrientation\" /\u003e\n```\n\n```java\nScanOptions options = new ScanOptions();\noptions.setOrientationLocked(false);\nbarcodeLauncher.launch(options);\n```\n\n### Customization and advanced options\n\nSee [EMBEDDING](EMBEDDING.md).\n\nFor more advanced options, look at the [Sample Application](https://github.com/journeyapps/zxing-android-embedded/blob/master/sample/src/main/java/example/zxing/MainActivity.java),\nand browse the source code of the library.\n\nThis is considered advanced usage, and is not well-documented or supported.\n\n## Android Permissions\n\nThe camera permission is required for barcode scanning to function. It is automatically included as\npart of the library. On Android 6 it is requested at runtime when the barcode scanner is first opened.\n\nWhen using BarcodeView directly (instead of via IntentIntegrator / CaptureActivity), you have to\nrequest the permission manually before calling `BarcodeView#resume()`, otherwise the camera will\nfail to open.\n\n## Building locally\n\n    ./gradlew assemble\n\nTo deploy the artifacts the your local Maven repository:\n\n    ./gradlew publishToMavenLocal\n\nYou can then use your local version by specifying in your `build.gradle` file:\n\n    repositories {\n        mavenLocal()\n    }\n\n## Sponsored by\n\n[JourneyApps][1]\n\n\n## License\n\nLicensed under the [Apache License 2.0][7]\n\n\tCopyright (C) 2012-2022 ZXing authors, Journey Mobile\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\t    http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n\n\n\n[1]: http://journeyapps.com\n[2]: https://github.com/zxing/zxing/\n[5]: zxing-android-embedded/src/com/journeyapps/barcodescanner/ScanOptions.java\n[7]: http://www.apache.org/licenses/LICENSE-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjourneyapps%2Fzxing-android-embedded","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjourneyapps%2Fzxing-android-embedded","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjourneyapps%2Fzxing-android-embedded/lists"}