private async void Export_Button_ClickedAsync(object sender, EventArgs e) { try { PermissionStatus status = PermissionStatus.Unknown; status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); if (status != PermissionStatus.Granted) { status = await PermissionUtility.CheckPermissions(Permission.Storage); } if (status == PermissionStatus.Granted) { string exportString = await _importExportService.GetExportLibraryContentAsync(); string downloadPath = DependencyService.Get <IFileHelper>().GetDownloadFolderPath("libraryBackup.json"); File.WriteAllText(downloadPath, exportString); await DisplayAlert("Success", "Your file has been successfully downloaded. You can find your file in your download folder, named 'libraryBackup.json'", "Ok"); } } catch (Exception ex) { await DisplayAlert("Error", ex.Message, "Ok"); Console.WriteLine("Exception exporting file: " + ex.ToString()); } }
private async Task ExecuteGetLocationCommand() { if (IsBusy) { return; } IsBusy = true; if (!IsConnected) { await MainPage.DisplayAlert("Message", "No Internet Access. Please connect.", "Try again"); IsBusy = false; return; } try { Tuple <WeatherApiResonseData, OneCallWeatherAPIResponseData> weatherInfo = await GetLocation(); await NotifyUpdateWeatherUI(weatherInfo.Item1, weatherInfo.Item2); } catch (Exception ex) { PermissionStatus status = await PermissionUtility.CheckPermissions(Plugin.Permissions.Abstractions.Permission.Location); if (status == PermissionStatus.Granted) { await MainPage.DisplayAlert("Message", "Please allow location services", "Ok"); } else { await MainPage.DisplayAlert("Message", "Please allow location permission", "Ok"); } } finally { IsBusy = false; } }
public async void CheckPermissions() { await PermissionUtility.CheckPermissions(Plugin.Permissions.Abstractions.Permission.Location); }