File selection is made with picker in my project where I make Xamarin Forms. The problem is that it always returns null.
my manifest
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
my code
var customFileType = new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
{
{ DevicePlatform.Android, new[] { "application/octet-stream" } }
});
var options = new PickOptions
{
PickerTitle = "Please select a .DB file",
FileTypes = customFileType,
};
try
{
var result = await FilePicker.PickAsync(options); //<= Returns null. But i selected file
if (result != null)
{
if (result.FileName.EndsWith("db", StringComparison.OrdinalIgnoreCase))
{
var fileByte = File.ReadAllBytes(result.FullPath);
string path = App.path + @"/" + result.FileName;
File.WriteAllBytes(path, fileByte);
StartViewModel viewModel = new StartViewModel(new StartPage());
App.Current.MainPage = viewModel.View;
}
}
}
catch (Exception ex)
{
// The user canceled or something went wrong
}
my Output Logs
Resolved pending breakpoint at 'StartPage.xaml.cs:119,1' to void PasswordSaver.Views.StartPage.<PickAndSaveFile>d__5.MoveNext () [0x0008c].
[Timeline] Timeline: Activity_launch_request time:400995680
[Timeline] Timeline: Activity_launch_request time:400995764
[DecorView[]] getWindowModeFromSystem windowmode is 1
[DecorView] createDecorCaptionView windowingMode:1 mWindowMode 1 isFullscreen: true
[Activity] Slow Operation: Activity com.developerPazl.passwordStore/crc64a0e0a82d0db9a07d.IntermediateActivity onActivityResult took 8205ms
[Looper] PerfMonitor longMsg : seq=1443 plan=09:41:11.653 late=2ms wall=8217ms running=57ms runnable=29ms h=android.app.ActivityThread$H w=159 procState=2
[Choreographer] Frame time is 0.02849 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase.
[Choreographer] Frame time is 0.009386 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase.
All packages have been updated. But there is no progress. Your answer will be appreciated.
Edit There is progress
Ok, I'm narrowing down the problem. I opened the simulator there, this code continued to work without any problems. But the problem continues on the Redmi Note 9 Pro
device. That doesn't explain how it behaves on specific devices. File Picker
not working on certain devices, reason unknown