title: Android: Registering Intent Filter to open email attachment with my app
body: <p>I have an app that generates custom file types (.sor). Inside the app I have a feature to send an email with one of these files attached. I also have an intent filter to allow the app to show up in the list of apps that can open this type of file. This allows me to (sometimes) open the file with the app right from the users email client on the phone.</p>
  
  <p>However, this only works when the email comes from a PC email client, and will not work when the email is received from a phone. For example, if I generate one of these .sor files and then use my app to send an email to my own email account I will receive the email on my phone but will not be able to open the attachment with my app... BUT, if I send the email to the same account and open it on my PC (with Thunderbird) instead of on the phone and then either forward it or send it as a new email to my phone I will be able to use the same email app on the phone to open the attachment with my app... I'm only talking about one email account here, the only difference is where the email was sent from, my phone or my windows 7 PC.</p>
  
  <p>The only thing I can think of is that when I send the email from the phone a different mime-type is being embedded into the attachment than when I send it from Thunderbird on my PC... I specify the mime type as "application/octet-stream" when I send out the email from my app, and I have an intent filter that looks for this mime type... but it does not work correctly.</p>
  
  <p>My intent filter:</p>
  
  <pre><code>&lt;intent-filter&gt;
    &lt;action android:name="android.intent.action.VIEW" /&gt;
    &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    &lt;data android:mimeType="application/octet-stream" /&gt;
    &lt;data android:scheme="file" /&gt;
  &lt;/intent-filter&gt;
  </code></pre>
  
  <p>The intent that I pass to the phones email client when sending the file in an email attachment from the phone:</p>
  
  <pre><code>Intent sendIntent = new Intent(Intent.ACTION_SEND);
  sendIntent.setType("application/octet-stream");
  sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + fullPathString));
  sendIntent.putExtra(Intent.EXTRA_SUBJECT, "FiberDroid OTDR Trace File: \"" + ContextMenuFileName + "\"");
  sendIntent.putExtra(Intent.EXTRA_TEXT, "This e-mail was sent from the TTI FiberDroid Android application.");
  startActivity(Intent.createChooser(sendIntent, "Select E-Mail Application"));
  </code></pre>
  
  <p>Again, the sending of the email with the file attached works correctly... and if I email the same file back to the phone from a PC email client (such as outlook or thunderbird) then I am able to open the file with my application directly from the phones email app. The problem is, if I open the email on the phone without going through my PC as a middleman I cannot open the attachment, the only option I am given is "Save to SD Card"...</p>
  
  <p>So to recap, I have 2 emails on my phone that are identical, with the same file attached and both originally sent from my application to the same account (both received from the same account also), but the attachment in the one that went through my PC as an unnecessary middleman works correctly, and the one sent and received directly from my phone does not.</p>
  
  <p>Any ideas? Thank you in advance.</p>