From be7987f88a44ef87577931fb5a2985cc24ed304c Mon Sep 17 00:00:00 2001 From: Dennis Guse Date: Sat, 21 Feb 2026 14:40:17 +0100 Subject: [PATCH] Bugfix: crash when exporting zero tracks. Fixes #2285 --- .../io/file/exporter/ExportActivity.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/io/file/exporter/ExportActivity.java b/src/main/java/de/dennisguse/opentracks/io/file/exporter/ExportActivity.java index c704fdebe..5b4343fe8 100644 --- a/src/main/java/de/dennisguse/opentracks/io/file/exporter/ExportActivity.java +++ b/src/main/java/de/dennisguse/opentracks/io/file/exporter/ExportActivity.java @@ -167,8 +167,11 @@ public class ExportActivity extends AbstractActivity { new Thread(() -> { directoryFiles = ExportUtils.getAllFiles(ExportActivity.this, documentFile.getUri()); runOnUiThread(() -> { - createExportTasks(allInOneFile); - nextExport(null); + if (createExportTasks(allInOneFile)) { + nextExport(null); + } else { + onExportEnded(); + } }); }).start(); } else { @@ -217,8 +220,12 @@ public class ExportActivity extends AbstractActivity { exportTasks.clear(); } - private void createExportTasks(boolean allInOneFile) { + private boolean createExportTasks(boolean allInOneFile) { List tracks = contentProviderUtils.getTracks(); + if (tracks.isEmpty()) { + return false; + } + exportTasks = new ArrayList<>(); if (allInOneFile) { String filename = "OpenTracks-Backup"; @@ -227,6 +234,7 @@ public class ExportActivity extends AbstractActivity { exportTasks.addAll(tracks.stream().map(it -> new ExportTask(null, trackFileFormat, List.of(it.id()))).toList()); } trackExportTotalCount = exportTasks.size(); + return true; } /** @@ -391,7 +399,7 @@ public class ExportActivity extends AbstractActivity { /** * Try to resolve the conflict if user gave the info needed. - * Otherwise shows the buttons and views needed to gives the user the possibility of take a decision. + * Otherwise, shows the buttons and views needed to gives the user the possibility of take a decision. * * @return true if it could resolve the conflict or false otherwise. */