OK, I've got this working and it wasn't so hard after all!

Thanks go to Alexey Krasnoriadtsev whose post got me heading in the
right direction -
http://groups.google.com/group/android-developers/browse_thread/thread/081fae2e99226a30/79303e5fbde3cd27?lnk=raot

The intent created by the gmail app on clicking on an attachment gives
a content provider uri. I'm assuming this content provider stores an
actual url to the attachment on google servers.

To get an input stream containing the attachment:

InputStream attachment = getContentResolver().openInputStream(getIntent
().getData());

Then I just used the following xml parsing code:

DocumentBuilder builder = DocumentBuilderFactory.newInstance
().newDocumentBuilder();
Document doc = builder.parse(attachment);
attachment.close();
Element recipe = doc.getDocumentElement();
....

You can view this in context in my source code at:
http://code.google.com/p/bites-android/source/browse/trunk/Bites/src/caldwell/ben/bites/Bites.java#313

On Aug 7, 9:22 am, Ben Caldwell <[email protected]> wrote:
> My app uses the below intent filter to make itself an xml file reader
> for the purpose of inserted data shared between users. This works fine
> with xml files viewed in the browser but I can not make it work with
> xml files sent as email attachments in the gmail app.
>
> <intent-filter>
> <action android:name="android.intent.action.VIEW" />
> <category android:name="android.intent.category.DEFAULT" />
> <category android:name="android.intent.category.BROWSABLE" />
> <data android:mimeType="text/xml" />
> </intent-filter>
>
> When I check the logcat output I can see that the gmail app starts
> downloading the attachment when I press the "Preview" button, but as
> soon as my activity is brought to the front the attachment download is
> cancelled and there is no data to parse.
>
> I see in the intent created from the gmail app there are a couple of
> ID numbers for the attachment. Perhaps someone has used these ID
> numbers to grab file attachments from the gmail servers?
>
> Anyone interested in how I am handling XML files so far please feel
> free to peruse the source of my project 
> athttp://code.google.com/p/bites-android/source/browse/trunk/Bites/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to