We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to Scan QR code from Gallery but I don't know how to do it.... can any one help me
Below is my code to fetch Image from gallery .....
btnUploadFromGallery.setOnClickListener(new View.OnClickListener() { @OverRide public void onClick(View v) {
Intent iGallery = new Intent(Intent.ACTION_PICK); iGallery.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(iGallery,200); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK){ if (requestCode == 200){ Uri ImageUri = data.getData(); scannerView.setResultHandler((ZXingScannerView.ResultHandler) ImageUri); } } }
The text was updated successfully, but these errors were encountered:
This discussion can help you.
Sorry, something went wrong.
private val openGalleryRequest = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { if (it.resultCode == AppCompatActivity.RESULT_OK) { it.data?.data?.let { uri -> decodeQRCode(uri) } } } private fun openGallery() { val intent = Intent() intent.type = "image/*" intent.action = Intent.ACTION_GET_CONTENT openGalleryRequest.launch(Intent.createChooser(intent, "Scan Gallery")) } private fun decodeQRCode(imageUri: Uri) { try { val inputStream = context?.contentResolver?.openInputStream(imageUri) val bitmap = BitmapFactory.decodeStream(inputStream) val intArray = IntArray(bitmap.width * bitmap.height) bitmap.getPixels(intArray, 0, bitmap.width, 0, 0, bitmap.width, bitmap.height) val source: LuminanceSource = RGBLuminanceSource(bitmap.width, bitmap.height, intArray) val binaryBitmap = BinaryBitmap(HybridBinarizer(source)) val reader = QRCodeReader() val result = reader.decode(binaryBitmap) // The QR code content is in result.text val qrCodeContent = result.text proceedQrData(qrCodeContent) } catch (e: Exception) { // Handle exceptions (e.g., QR code not found) } }
No branches or pull requests
I want to Scan QR code from Gallery but I don't know how to do it.... can any one help me
Below is my code to fetch Image from gallery .....
btnUploadFromGallery.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
The text was updated successfully, but these errors were encountered: