-1

I have created an app that could generate qrcode.My question is, is it possible to save the generated bitmap in phone storage and firebase at the same time.Any help would be appreciated.

My code for generating qr code :

gen_btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ObtainText = Text.getText().toString().trim();
            MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
            try {
                BitMatrix bitMatrix = multiFormatWriter.encode(Text.getText().toString(), BarcodeFormat.QR_CODE, 200, 200);
                BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
                Bitmap bitmap = barcodeEncoder.createBitmap(bitMatrix);
                image.setImageBitmap(bitmap);

            } catch (WriterException e) {

                e.printStackTrace();
            }
        }
    }) ;

My idea :

enter image description here

cklai
  • 41
  • 1
  • 1
  • 10

1 Answers1

0

First, Never handle bitmap operations and other same heavy operations in UI thread. You should handle it asynchronously or in a service thread.

Inorder to save this bitmap in your local storage, You can use cache directory or external storage.

Save bitmap to location

You can use the same thread to upload the file into Firebase storage (It is also handled in another seperate thread).

https://firebase.google.com/docs/storage/android/upload-files

Athul Antony
  • 220
  • 2
  • 8