-
-
Save parzibyte/7c3d76d03e64f26d0ec39cbc599a523d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Crear stream del código QR | |
ByteArrayOutputStream byteArrayOutputStream = QRCode.from(texto).stream(); | |
// E intentar guardar | |
FileOutputStream fos; | |
try { | |
// Guardar en el almacenamiento externo con el nombre de "codigo.png" | |
fos = new FileOutputStream(Environment.getExternalStorageDirectory() + "/codigo.png"); | |
byteArrayOutputStream.writeTo(fos); | |
Toast.makeText(MainActivity.this, "Código guardado", Toast.LENGTH_SHORT).show(); | |
} catch (FileNotFoundException e) { | |
// Nota: aquí indica al usuario que algo salió mal | |
e.printStackTrace(); | |
} catch (IOException e) { | |
// Nota: aquí indica al usuario que algo salió mal | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment