We have a Xamarin Forms app that has a tab view. From one of the tabs, we open a new Content Page, which needs to have an option to select files and upload the attachment. Using Xamarin.Essentials FilePicker, we are able to pick the file and read the file contents, but after the file is read, the app auto-navigates to the home screen - the same as an app restart.
We have observed that when the filepicker is opened, OnSleep in the App.xaml.cs is called and when the file is read and the picker is dismissed, onresume in App.xaml.cs is called. It seems like this could cause the XForms App to be restarted completely.
All permissions are in place - we are targeting Android 9.0, using XForms version 4.8, X.Essentials v1.6.
Can you please help?
Relevant code:
try
{
var file = await FilePicker.PickAsync();
if (file != null)
{
var stream = await file.OpenReadAsync();
byte[] FileData = new byte[stream.Length];
await stream.ReadAsync(FileData, 0, (int)(stream.Length - 1));
fileData = Convert.ToBase64String(FileData);
fileStream = new MemoryStream(FileData);
FileNameVisibility = true;
FileName = file.FileName;
}
}
catch (Exception ex)
{
Crashes.TrackError(ex);
}