Skip to content
New issue

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

android file export error #76

Open
lopallo opened this issue Sep 6, 2023 · 2 comments
Open

android file export error #76

lopallo opened this issue Sep 6, 2023 · 2 comments

Comments

@lopallo
Copy link

lopallo commented Sep 6, 2023

Hello, on Android with version 0.1.1 I had no problem to export a file, but using version 0.2.8 I get this error:
D/FileSaver( 5086): Error While Calling methodNo Activity found to handle Intent { act=android.intent.action.CREATE_DOCUMENT cat=[android.intent.category.OPENABLE] flg=0xc3 (has extras) }

@incrediblezayed
Copy link
Owner

Hello, on Android with version 0.1.1 I had no problem to export a file, but using version 0.2.8 I get this error:
D/FileSaver( 5086): Error While Calling methodNo Activity found to handle Intent { act=android.intent.action.CREATE_DOCUMENT cat=[android.intent.category.OPENABLE] flg=0xc3 (has extras) }

Which android version and can you possibly share a code block?

@lopallo
Copy link
Author

lopallo commented Sep 6, 2023

I verified with Nexus 5Xapi30 emulator and with smartphone with Android 13

Future exportTurni() async {
String esporta = await dbTurni.exportDbTurni();
final directory = await getApplicationDocumentsDirectory();
final path = directory.path;
File file = File('$path/turni_mensili.json');
await file.writeAsString(esporta);
//controlla se il file è stato effettivamente esportato
if (file.existsSync()) {
//esporta il file
Uint8List bytes = file.readAsBytesSync();
FileSaver.instance.saveAs('turniMensili', bytes, 'json', MimeType.JSON);
} else {
//mostra un messaggio di errore
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Errore durante l'esportazione del file',
),
),
);
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants