如何從我的應用程序共享音頻文件到其他應用程序並從其他應用程序接收音頻文件?Xamarin-ios共享和接收音頻文件
我無法附加的音頻文件。這裏是代碼片段:
var fileData = NSUrl.FromFilename(path);
var item = UIActivity.FromObject(@"<html><body><b>URL</b>: <a href='" + url + "'>" + url + "</a></body></html>");// NSObject.FromObject(uiImage);
var activityItems = new[] { fileData };
NSString message = (NSString)"Test";
var activityController = new UIActivityViewController(activityItems, null);
activityController.SetValueForKey(NSObject.FromObject("The subject value"), new NSString("subject"));
var topController = UIApplication.SharedApplication.KeyWindow.RootViewController;
while (topController.PresentedViewController != null)
{
topController = topController.PresentedViewController;
}
topController.PresentViewController(activityController, true,() => { });
我還想添加主題和身體,如果文件附加爲郵件。
試過,但沒有運氣,得到一個錯誤:
activityController.SetValueForKey(NSObject.FromObject("The subject value"), new NSString("subject"));
activityController.SetValueForKey(NSObject.FromObject("The body value"), new NSString("body"));
此外,我希望收到其他應用共享的音頻文件。我使用依賴項服務和意圖過濾器完成了android中的功能。對於android代碼已被添加到mainactivity.cs中,我使用意圖過濾器接受來自其他應用程序的音頻文件。如何在iOS中做到這一點?
什麼錯誤,你一直得到些什麼? – BytesGuy
它不會將附件或內容添加到郵件中。 – Arti