Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 11, 2019 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/7c3d76d03e64f26d0ec39cbc599a523d to your computer and use it in GitHub Desktop.
Save parzibyte/7c3d76d03e64f26d0ec39cbc599a523d to your computer and use it in GitHub Desktop.
// 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