title: Opening an unknown file type in Android (6.0)
body: <p>Instead of telling a user that they cannot open their file b/c <em>"there are no supported apps"</em> (ie Samsung) or something, I wan't to let them choose an app, like <strong>Asus</strong> (KitKat) does with their <strong>File Manager</strong>. Opening a file named <em>test.noapp</em> gives the following prompt</p>
  
  <p><a href="https://i.stack.imgur.com/C0hKZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C0hKZ.jpg" alt="enter image description here"></a></p>
  
  <p>Choosing <em>Text</em> then gives a list of text-processing apps</p>
  
  <p><a href="https://i.stack.imgur.com/UcD2f.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UcD2f.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Do I have to roll my own <em>"Open as"</em> category list, or is there something in the API (level 23) that I can leverage?</strong></p>
  
  <hr>
  
  <p>The following code is used to open files</p>
  
  <pre><code>Intent viewFileIntent = new Intent(Intent.ActionView);
  
  Android.Net.Uri uriFile = Android.Net.Uri.FromFile(selectedAttachmentDetails.File);
  string mimeType = GetAttachmentFileTypeMimeString(selectedAttachmentDetails.File.Name);
  
  viewFileIntent.SetDataAndType(uriFile, mimeType);
  
  THIS.StartActivityForResult(Intent.CreateChooser(viewFileIntent, "Complete action using"), 0);
  
  private string GetAttachmentFileTypeMimeString(string attachmentFileName)
  {
      string ext = Android.Webkit.MimeTypeMap.GetFileExtensionFromUrl(attachmentFileName);
      Android.Webkit.MimeTypeMap map = Android.Webkit.MimeTypeMap.Singleton;
  
      string mimeType = map.GetMimeTypeFromExtension(ext);    
  
      return mimeType == null ? "*/*" : mimeType;
  }
  </code></pre>