catch exception while sending log data. might throw if too much data is sent.

This commit is contained in:
Philipp Crocoll
2025-06-17 14:58:06 +02:00
parent 2d17bdde19
commit 40184dbd55

View File

@@ -116,12 +116,23 @@ namespace keepass2android
Intent sendIntent = new Intent(); Intent sendIntent = new Intent();
sendIntent.SetAction(Intent.ActionSend); sendIntent.SetAction(Intent.ActionSend);
sendIntent.PutExtra(Intent.ExtraText, File.ReadAllText(LogFilename)); string logText = File.ReadAllText(LogFilename);
sendIntent.PutExtra(Intent.ExtraText, logText);
sendIntent.PutExtra(Intent.ExtraEmail, "crocoapps@gmail.com"); sendIntent.PutExtra(Intent.ExtraEmail, "crocoapps@gmail.com");
sendIntent.PutExtra(Intent.ExtraSubject, "Keepass2Android log"); sendIntent.PutExtra(Intent.ExtraSubject, "Keepass2Android log");
sendIntent.SetType("text/plain"); sendIntent.SetType("text/plain");
ctx.StartActivity(Intent.CreateChooser(sendIntent, "Send log to...")); try
} {
ctx.StartActivity(Intent.CreateChooser(sendIntent, "Send log to..."));
}
catch (Exception e)
{
Toast.MakeText(ctx, $"Error sending log of length {logText.Length} bytes: " + e.Message, ToastLength.Long)?.Show();
}
}
public static void LogTask(object task, string activityName) public static void LogTask(object task, string activityName)
{ {