Sep 20 | 7:20 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Sep 20 | 7:40 PM |
Kathy | has entered the room |
Mark M. |
howdy, Kathy!
|
Kathy |
hi
|
Mark M. |
how can I help you today?
|
Ron B. | has entered the room |
Ron B. |
Hi Mark!
|
Mark M. |
howdy, Ron!
|
Mark M. |
Kathy: do you have a question?
|
JamesMoore | has entered the room |
Mark M. |
gadzooks, it's a veritable army of chatters! :-)
|
Kathy |
I want to write a jpeg to the SD card and wanted to know the best way to do it.
|
Mark M. |
howdy, James!
|
JamesMoore |
Hello
|
Mark M. |
Kathy: that's mostly just standard Java I/O
|
JamesMoore |
So I've been playing around a bit with scala
|
Kathy |
I am also not sure what folder to put the jpeg in. I am going to allow the user to save a wallpaper image.
|
Mark M. |
James: hang on, let me take things one at a time
|
JamesMoore |
sure, no problem
|
Kathy |
Does every phone have the same folder where the photos are put?
|
Mark M. |
Kathy: if your app is only for API Level 8
(Android 2.2) and up, use
Environment.getExternalStoragePublicDirectory() to find out where to
write your JPEGs
|
Mark M. |
you also will need the WRITE_EXTERNAL_STORAGE permission
|
Sep 20 | 7:45 PM |
Kathy |
What does that tell me, does it tell me the folder also?
|
Mark M. |
and you will want to consider whether or not external storage is presently available (see Environment.getExternalStorageState())
|
Mark M. |
getExternalStoragePublicDirectory() tells you the preferred directory for various data formats
|
Mark M. |
getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) would tell you where to store images
|
Mark M. |
it returns a File object pointing to the directory
|
Mark M. |
there's an extensive sample in the documentation for that method
|
Ron B. |
View paste
(8 more lines)
|
Ron B. |
Sorry, didn't mean to cut in
|
Mark M. |
Kathy: let me take questions from the others, and I can swing back around to you for follow-up
|
Mark M. |
Ron, you were next into the chat
|
Kathy |
I am almost done. I was looking in the samples to try and fine a write to SD samples but I could not seem to find it.
|
Kathy |
Oh, sorry, I can wait.
|
Mark M. |
when you say "does not seem to find the file", what do you mean?
|
Ron B. |
I get a file not found from gmail, and false on file.exists()
|
Mark M. |
um, there's no exists() on InputStream
|
Ron B. |
On File.
|
Mark M. |
but there's no File from a ContentProvider
|
Mark M. |
getContentResolver().openFile(), which is what Gmail presumably uses, gets an InputStream
|
Ron B. |
I get the file from the URI:
|
Ron B. |
View paste
|
Sep 20 | 7:50 PM |
Mark M. |
but if the Uri is content://..., you can't just magically turn that into a File
|
Ron B. |
So what do I do with it?
|
Mark M. |
I can't answer that
|
Mark M. |
since I have no idea what you are trying to do
|
Ron B. |
I want gmail to send the file, I need a content provider to allow gmail to do this?
|
Mark M. |
yes
|
Ron B. |
The content provider needs an openFile method, right?
|
Mark M. |
yes
|
Mark M. | |
Mark M. |
View paste
|
Mark M. |
in this case, the expected Uri would be of the form FileProvider.CONTENT_URI+"geoweb2.html"
|
Mark M. |
IOW, content://com.commonsware.android.cp.files/geoweb2.html
|
Ron B. |
OK, I'll try that. Thanks!
|
Mark M. |
OK
|
Mark M. |
James: your turn
|
JamesMoore |
Playing with scala. Is there a way to use a different ClassLoader for an app?
|
JamesMoore |
Dev time only
|
Mark M. |
not for the whole app
|
Mark M. |
short of modifying firmware
|
JamesMoore |
Looked like you could replace the class loader using the Instrumentation class
|
Mark M. |
that's possible, haven't looked at that
|
JamesMoore |
OK - is there something like Instrumentation for sesrvices?
|
Mark M. |
I'm used to thinking solely for production
|
JamesMoore |
Sure, makes sense
|
Mark M. |
AFAIK, Instrumentation works for services
|
Sep 20 | 7:55 PM |
Mark M. |
after all, there's a ServiceTestCase class, IIRC
|
JamesMoore |
Right, the problem is there's no call to something newService() like there is for newActivity()
|
Mark M. |
oh
|
JamesMoore |
Feels like it should be there
|
Mark M. |
I haven't played with custom instrumentation much
|
Mark M. |
agreed, you would think it would be there for all components
|
JamesMoore |
Fair enough - didn't want to spend time on it if
|
JamesMoore |
it was somethign you migh tknow about already
|
Mark M. |
yeah, sorry, outside my areas of experience
|
JamesMoore |
worth a shot, thanks
|
Mark M. |
Kathy: you're up again -- got another question or follow-up on the first?
|
Kathy |
Yes, thanks for your help. Can you tell me where
the sample is? I was looking at the android dev samples last night and
did not find it.
|
Mark M. |
I was referring to the JavaDocs, for the getExternalStoragePublicDirectory() on Environment
|
Mark M. | |
Mark M. |
(that link will jump right to the method)
|
Kathy |
Okay, thanks so much.
|
Mark M. |
Ron: do you have another question or a follow-up to your first?
|
Ron B. |
Thanks Mark, I just tried your fix and it worked! I didn't have the right File parameters.
|
Mark M. |
oh, whew
|
Sep 20 | 8:00 PM |
Mark M. |
I got worried when I realized that I misunderstood where you were trying to use the File object
|
Mark M. |
I thought you were trying to *consume* the content provider with it, not support openFile()
|
JamesMoore |
(nothing more from me, just hanging out now)
|
Mark M. |
well, it's a free-for-all now, at least unless somebody else new shows up
|
Ron B. |
No, it was in the right spot, just wrong code :-)
|
Mark M. |
anyone with a question, chime in
|
Ron B. |
All set here
|
JamesMoore |
any way to get the nice text selection system in
2.3 in versions before that? handles on the selection that can be
dragged, that sort of thing
|
JamesMoore |
don't need copy/paste, just select
|
Mark M. |
not that I am aware of
|
Mark M. |
I suppose you could poke around the source for EditText and see how they do it
|
JamesMoore |
or external libraries that do something useful?
|
Kathy |
I wish I could think up a question right now but I
was just looking around your docs and thought I would just check and
see if there was an office chat and voila, so I have no prepared
questions right now.n
|
JamesMoore |
Yeah, I was hoping to avoid that :-)
|
Mark M. |
however, it might run into problems on various devices
|
Mark M. |
I haven't seen a library for extending EditText with selection stuff, but I haven't exactly been looking
|
Mark M. |
the world needs a sexy go-to Android component library site
|
JamesMoore |
that would be handy
|
Sep 20 | 8:05 PM |
JamesMoore |
thanks, ltr
|
Mark M. |
see ya!
|
Sep 20 | 8:15 PM |
Mark M. |
again, if anyone has a question, feel free to ask
|
Sep 20 | 8:30 PM |
Mark M. |
OK, that's a wrap for today's chat
|
Mark M. |
another one Thursday. same time
|
Mark M. |
have a pleasant day, all!
|
Kathy | has left the room |
Ron B. | has left the room |
JamesMoore | has left the room |
Mark M. | turned off guest access |