[android-developers] Re: Returning files through a Cursor
On Sep 3, 10:13 am, David Given d...@cowlark.com wrote: We've got it *nearly* working; I can see GMail call query() on my ContentProvider, followed shortly by GMail crashing because I'm not providing the right fields in the cursor. The thing is --- what's GMail expecting to see? I can't find any documentation on this. I wonder if its expectations are close enough to those of the sources- provided non-gmail Email application that you could debug it against that and then switch back to gmail? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Returning files through a Cursor
Did you try putExtra(Intent.EXTRA_STREAM, uri) ? // the following code snippet will attach a file from a content resolver and send it via email/mms. Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(...); sendIntent.putExtra(Intent.EXTRA_STREAM, uri); // attachment sendIntent.putExtra(Intent.EXTRA_SUBJECT, getResources().getText (R.string.subject)); startActivityForResult(Intent.createChooser(sendIntent, getResources ().getText(R.string.app_name)), ACTIVITY_SEND); Balwinder Kaur Open Source Development Center ·T· · ·Mobile· stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Sep 3, 7:41 am, Chris Stratton cs07...@gmail.com wrote: On Sep 3, 10:13 am, David Given d...@cowlark.com wrote: We've got it *nearly* working; I can see GMail call query() on my ContentProvider, followed shortly by GMail crashing because I'm not providing the right fields in the cursor. The thing is --- what's GMail expecting to see? I can't find any documentation on this. I wonder if its expectations are close enough to those of the sources- provided non-gmail Email application that you could debug it against that and then switch back to gmail? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Returning files through a Cursor
On Thu, Sep 3, 2009 at 7:13 AM, David Givend...@cowlark.com wrote: I would like my app to start an email app such as GMail with an attached file. For various technical reasons we can't use a file: URL for this --- we have to pull the file out of our ContentProvider. So, I need some way to make a content: URL behave as if it were a file. You can implement openFile() in your content provider to return a FileDescriptor for that content Uri. This is what pretty much every content provider does for things like this. We've got it *nearly* working; I can see GMail call query() on my ContentProvider, followed shortly by GMail crashing because I'm not providing the right fields in the cursor. A Cursor is not a file, so not sure what you're trying to do here. The thing is --- what's GMail expecting to see? I can't find any documentation on this. I have found ContentProvider#getAssetFile(), which appears to be related, but it doesn't seem to being called. What I get is: E/CursorWindow( 848): Bad request for field slot 0,1. numRows = 1, numColumns = 1 Something is trying to get the 2nd column from a Cursor that has only 1 column. (What I'd really like to do is to be able to pass GMail some sort of high-level stream object so that I can generate data on the fly, but I suspect it's not possible.) -- ┌─── dg@cowlark.com ─ http://www.cowlark.com ─ │ │ They laughed at Newton. They laughed at Einstein. Of course, they │ also laughed at Bozo the Clown. --- Carl Sagan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Returning files through a Cursor
Chris Stratton wrote: [...] I wonder if its expectations are close enough to those of the sources- provided non-gmail Email application that you could debug it against that and then switch back to gmail? Yes, of course I can... For reference, what GMail (and Email) want is a cursor conforming to OpenableColumns, containing the name and size of the file (if known). Once the app has read those it'll try to open the file via ContentResolver#openInputStream(). So that bit's all working fine. However, I can't find a way of passing a stream through a ParcelFileDescriptor. I really don't want to have to write my file out to disk because figuring out when to clear up the temporary file becomes nasty. What I'd really like is a pipe, so that I can create the data as the email app asks for it --- but it doesn't appear to be possible to create a ParcelFileDescriptor from a pipe, or a unix socket, etc. Is there any way to do this? I may have to resort to creating a unix socket in my application sandbox and lying to GMail about it being a file. -- ┌─── dg@cowlark.com ─ http://www.cowlark.com ─ │ │ They laughed at Newton. They laughed at Einstein. Of course, they │ also laughed at Bozo the Clown. --- Carl Sagan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---