public void PickSoundForNotificationChannel() { if (NotificationChannelsApiCheck()) { return; } AGFilePicker.PickAudio(audioFile => { _soundFilePath = AndroidUri.FromFile(audioFile.OriginalPath).CallStr("getPath"); Debug.Log(_soundFilePath); AGUIMisc.ShowToast(_soundFilePath); }, error => AGUIMisc.ShowToast("Cancelled picking audio file")); }
internal static AndroidUri GetShareableFileUri(string filename) { Java.IO.File sharedFile; //if (FileProvider.IsFileInPublicLocation(filename)) //{ // // we are sharing a file in a "shared/public" location // sharedFile = new Java.IO.File(filename); //} //else //{ var rootDir = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), filename); //var rootDir = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);// FileProvider.GetTemporaryDirectory(); // create a unique directory just in case there are multiple file with the same name var tmpDir = new Java.IO.File(rootDir, Guid.NewGuid().ToString("N")); tmpDir.Mkdirs(); tmpDir.DeleteOnExit(); // create the new temprary file var tmpFile = new Java.IO.File(tmpDir, System.IO.Path.GetFileName(filename)); System.IO.File.Copy(filename, tmpFile.CanonicalPath); tmpFile.DeleteOnExit(); sharedFile = tmpFile; //} // create the uri if (HasApiLevelN) { var providerAuthority = AppContext.PackageName + ".fileProvider"; return(FileProvider.GetUriForFile( AppContext.ApplicationContext, providerAuthority, sharedFile)); } return(AndroidUri.FromFile(new Java.IO.File(filename))); }