How to share Bitmap Generated Image

Asked

Viewed 51 times

0

Staff would like to know how I share an image generated within the app,

in the scope of the app the person writing in the text view captures and generates an image would like to share that image via Whats or email.

private void gerarQRCode() {

    String texto = edtTexto.getText().toString();
    MultiFormatWriter multiFormatWriter = new MultiFormatWriter();

    try {

        BitMatrix bitmatrix = multiFormatWriter.encode(texto, BarcodeFormat.QR_CODE, 2000, 2000);
        BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
        Bitmap bitmap = barcodeEncoder.createBitmap(bitmatrix);
        ivQRCode.setImageBitmap(bitmap);
    } catch (WriterException e) {

        e.printStackTrace();

    }
}

1 answer

0

You can pass a Intent being in charge of the user choosing which application he wants to complete the action with. See if this solves his problem:

Intent intent = new Intent(Intent.ACTION_SEND);
       intent.setType("image/*");
       intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file));// Passe ao path da imagem aqui

startActivity(Intent.createChooser(intent, "Share image using"));

https://developer.android.com/guide/components/intents-filters?hl=pt-br

  • Thanks Ivan, I’ll try and comment if it went well big hug.

  • Ivan, gave error, theoretically is generated a bitmap image is that image I would like to share.

  • Hello @Almirkubo! Please show console error message.

  • the app the person type a text and appears a qr code that image I can not share with code you showed me it opens the Internet but does not pass =.

  • This is really weird. This code forces an application selector, I believe that the device has at least one application capable of solving the action. You can not send this image directly to Whatsapp. You must send Uri and let him take care to locate the image by "address". Edit the question with the new code and error log or it will be impossible to resolve the issue.

  • Got it, thanks Ivan.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.