Office Hours — Today, March 30

Thursday, March 25

Mar 30
7:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
8:00 PM
George S.
has entered the room
George S.
Hello Mark.
Mark M.
howdy!
George S.
I emailed you about the shared preferences issue.
I'm still having no luck with it.
I'm unable to read a value from a ListPreference
Mark M.
OK
Have you looked at the relevant examples from my books, to see where things differ?
Just trying to figure out how best to go about resolving your problem...
George S.
I've looked thru your book and others and everything I find close to what I'm doing says I'm doing this correctly. I debug agains the Droid phone
8:05 PM
Mark M.
OK
George S.
It's odd for sure. I have the lists, I can show the preferences, etc. No errors are presented, unless somethings hidden in the log
Mark M.
Can you toss your arrays.xml file into a pastebin somewhere and link to it here in the chat?
George S.
yes...
oh.. pastebin... I've never used one of those.
Mark M.
Have you tried reading your preference via getString() instead of getInt(), since your ListPreference is made up of strings?
George S.
yes...
Mark M.
and what happens when you do?
George S.
nothing
samething.
no errors in the designer.
8:10 PM
George S.
I'm not great with debugging yet on this platform so there may be a way to get information I'm missing, with regards to any errors
Mark M.
oh, wait
you're using the wrong SharedPreferences
George S.
I've tried both
Mark M.
View paste
instead of SharedPreferences preferences = getSharedPreferences(PREF_FILE_NAME, MODE_PRIVATE);
George S.
getdefault and that one
Mark M.
getDefaultSharedPreferences() is the right answer for ordinary PreferenceActivity cases
have you tried running my samples on your DROID?
George S.
no.
Mark M.
OK, try the Prefs/Dialogs one
George S.
I've only used them as a guide. Along with a bunch of googling.
Mark M.
that has a ListPreference
either it works on your DROID, or it doesn't
George S.
ya, harder to find examples that fit my need
ok
Mark M.
if it does, you have to find the differences -- there's no other way I can debug it for you
if it fails, that'll stun me, but let me know
George S.
bummer.. ok.
another issue that thru me but I figured out
Mark M.
for the code you have, stick with getDefaultSharedPreferences() and getString()
George S.
ok
on the array file
both string then right (not a mix of string and array for the actual values)?
Mark M.
your arrays.xml file seems OK, if that is what you mean
George S.
ya.. sorry lol
one more thing right off
I ran into using "this" verses "getApplicationContext()" verses "[activity_name_here.this]"
8:15 PM
8:15 PM
Mark M.
most likely, you do not want getApplicationContext()
George S.
I spend hours and realized I could use "main.this"
What are the differences?
Mark M.
getApplicationContext() is useless, MyActivity.this is not :-)
George S.
lol
Mark M.
Your Activity is a perfectly suitable Context wherever you need one
George S.
good.. good that will narrow that down for me.
Mark M.
getApplicationContext() will return the Application object associated with your process
not that useful, particularly for UI-related stuff
George S.
ah, okay thanks. I have another if you are up for it?
Mark M.
blows up, etc.
go ahead
George S.
ok.. thx
I'm looking at renameTo() tonight....
I want to take a file on the sd card, renamed it (or copy and paste it if you will)
Mark M.
OK
George S.
so I have an audio file that is on the sd card. ive got a AlertDialog that comes up.. I want to grab that value (string) and use it in the path.
Mark M.
OK
George S.
so that the user can have the audio file named they way they want it and the other file gets removed. then upon the next recording the 3gpp gets made again. I just need the rename issue solved.
thx
Svetlin S.
has entered the room
8:20 PM
Mark M.
howdy, Svetlin!
George: was there a question related to renameTo()?
Svetlin S.
Hi to all!
George S.
yes. I just wanted to flesh it out a bit, big picture stuff.
Hello.
Mark M.
what you are describing sounds OK
George S.
ok. can you do a code snippet up on that?
Mark M.
On calling renameTo()?
that's just standard Java
George S.
yes please
Oh, I'm new to Java... lol
Mark M.
George S.
ok thx.
I'm all done, thanks again Mark.
Mark M.
Svetlin: did you have a question?
George: no problem
Svetlin S.
Yes, I have two questions regarding the camera functionality.
Firstly, I am trying to start it and just take a picture, however the picture is too small.
Here is the code:
View paste
    cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI
        .toString());
    startActivityForResult(cameraIntent, CAMERA_ACTIVITY);
8:25 PM
Svetlin S.
and then in onActivityResult
View paste
      switch (requestCode)
      {
        case CAMERA_ACTIVITY:
          Bundle b = intent.getExtras();
          Bitmap bm = (Bitmap) b.get("data");
          MediaStore.Images.Media.insertImage(getContentResolver(), bm, null, null);
          break;
      }
Mark M.
OK
I have not used this technique
I tend to create my own Camera activity, for greater control
I have heard others with a similar image-size issue
I do not know what the problem is, though, off the top of my head
Svetlin S.
The interesting thing is that this way I am starting the camera intent with the option to change settings.
So I see in the setting of the started intent that, say 5MP, Fine quality is chosen.
And still the resulting image is just 5-7K in size.
(I don't need more control over the camera, this would be fine)
Will you take a look maybe later, Mark, or do you suggest I'd rather post this in the forums?
Mark M.
You'll have better luck in the forums, I think
Svetlin S.
OK.
Mark M.
I will eventually look to experiment with that technique, but probably not any time soon
Svetlin S.
Second question, then.
8:30 PM
Svetlin S.
What is the proper/best way to resize/compact an image for upload to a web service?
Mark M.
Wait, first the images are too small, and now they're too big? :-)
Svetlin S.
I am giving the option to the user to choose of all images, regardless of how they are taken.
E.g. the user has used the camera standalone (which results in ~800K file), and only after that to use my app just for upload.
Mark M.
Bitmap has a createScaledBitmap() method
Svetlin S.
What about:
View paste
      BitmapFactory.Options opts = new BitmapFactory.Options();
      opts.inSampleSize = 4;

      Bitmap bitmap = BitmapFactory.decodeStream(fis, null, opts);
OK, but then how do I convert the Bitmap to, say, ByteArrayOutputStream?
Mark M.
That might work
Svetlin S.
I'd have to use BitmapFactory.Compress() and that has disastrous effect, no matter which quality I choose..
Right? Or is there another way?
View paste
      if (imageFilePath.endsWith(".jpg"))
      {
        bitmap.compress(CompressFormat.JPEG, 100, baos);
      }
NetApex
has entered the room
Mark M.
I haven't used any of the Bitmap conversion methods
Mostly because I haven't been creating images on-device, just consuming them from elsewhere
howdy, NetApex!
8:35 PM
Mark M.
I'm sorry that I'm not expert in your particular topics this evening
NetApex
Good evening
Svetlin S.
OK, how do I convert the Bitmap to a byte[] ot ByteArrayOutputStream then...?
Mark M.
A Bitmap isn't a PNG or JPEG
so, you'd have to write the Bitmap out to a file (e.g., via compress()) and use it that way, AFAIK
Svetlin S.
I see. OK, thanks Mark!
I think I am done now.
Again, much appreciated.
Mark M.
sorry I couldn't be of greater help
anyone else have a question?
George S.
I do if no one does... lol
NetApex?
NetApex
Go for it
George S.
ok.. thx
Svetlin S.
Have a good night, everyone :-) !
George S.
I'd like to take the 3gpp file Mark and convert it or it's contents as it were to .mp3
same to you Svetlin.
8:40 PM
Mark M.
3gpp video file?
George S.
oh, audio.
Svetlin S.
has left the room
George S.
I'm using MediaPlayer and MediaRecorder to capture such. It would really help if such could get into .mp3 format
at the least .wav
Mark M.
Write a Web service and upload it there to do a conversion
I do not believe you're going to get much in the way of transcoding help of that nature built into Android
NetApex
Lol and now you are heading towards my question.
Mark M.
You could look at the NDK and using some existing transcoding C library, I suppose
George S.
ah, both great ideas.
Thanks for those. NetApex, I'm done.
NetApex
Ok
There is a site savevid.com that lets you put in a url of a website that has a video and it gives you back a mp4 version (among others) that you can download.
George S.
ah, thanks.
8:45 PM
NetApex
I am trying my best to figure out the best way to hand off the url to them and get the output back in a way I can say "this is the file, start streaming"
Mark M.
well, you're going to have some issues
NetApex
lol
that was not the answer I was hoping for.. but the one I was afraid of
Mark M.
First, you'll want to check their terms of service to see if that's legal
NetApex
Already have an email off to them for permission
Mark M.
Then, there's a very good chance their MP4 output is not going to be "safe for streaming"
NetApex
Ugh, didn't consider that part
Mark M.
I would manually upload a file, manually get the URL to the MP4, and embed that in a VideoView (or use my vidtry sample app), and see if it plays on a device
If it does, then, since they don't appear to have a Web service API, you'll need to simulate form input and do some HTML scraping
If it does not play back, either they add more smarts to their side, or you're screwed
NetApex
I pulled a file using their site and uploaded it onto my site and tested the streaming in one of my (ok, two) soundboards just to get some others feed back on it... so far it's ok
Mark M.
bear in mind that with a VPS, you could accomplish the same thing yourself with Handbrake and MP4Box, and get safe for streaming results
OK, well, that sounds like you're getting lucky on the file conversion
NetApex
ok handbreak and mp4box... must Google those
Mark M.
Handbrake is a DVD ripper and format converter, a bit easier to use than mplayer or ffmpeg directly
MP4Box is the class "oh, fix the $#(#)#$( safe for streaming problem" tool
s/class/classic/
NetApex
Ahh, but it is something that isn't an on the fly thing though right?
Mark M.
Neither is theirs
8:50 PM
Mark M.
after all, you downloaded the file
NetApex
Yes, but you type in a link to say a youtube, facebook, funny or die... video or whatever and it feeds you the mp4 version back.
Mark M.
Right
NetApex
Never really looked at how it works behind the scenes
Mark M.
I seem to recall there are some FLV downloaders
regardless, to try to use their site programmatically, you're going to have to pretend to be a Web browser via HttpClient or something
NetApex
ok, if anything, this will definitely be a learning experience.
Mark M.
gonna be a bit icky
not a straight-up form
uses javascript for the submission
NetApex
Heck, your vidtry app taught me a lot!
Mark M.
Yeah, I'm kinda pleased how well that sample worked
NetApex
Yeah I saw that part, the javascript will be a pain for me to make work
Mark M.
Served me well when writing the first cut of the Howcast client
NetApex
It's very impressive.. I just need to figure out what I did wrong when I put it in my app
8:55 PM
NetApex
the video doesn't start moving the progress bar and you have to hit pause/play after you already hit go before it starts playing. Minor issue I suppose
Mark M.
that's a bit odd
George S.
Mark, where can we download the source code for your books?
Mark M.
Visit the main Web site (http://commonsware.com), visit the page for the book in question, and look for the Source Code link
It'll point you to my github page
George S.
ok, thanks.
Mark M.
everything is in a set of github repos
George S.
great... I'm heading there now.
NetApex
I should check and see if there are other websites out there that do the same thing with an easier interface
George S.
That would be great.
NetApex
Or heck.. figure out how they do that and make my own site.
George S.
lol ya.
Is there any other tidbits, gotchas you ran into that you have learned from. Like my main.this?
Mark M.
Enough to fill three books :-)
(with a fourth on the way)
George S.
Write em!
Mark M.
I already did
NetApex
He has lol
And I am dying for the 4th!
I hope it includes Live Wallpaper!
George S.
I need one that does just the main.this type goofy ones. lol
9:00 PM
George S.
a pocket guide maybe. lol
Mark M.
No live wallpaper, sorry
Fourth book is _Android Beyond Java_
alternative app development frameworks (e.g., Phone Gap)
scripting languages
and the NDK
George S.
ah, good the NDK.
NetApex
Interesting!
Mark M.
easy for you to say
makefiles give me the cold sweats
George S.
What do you think of the Corona SDK for Android announcement, heard of it?
Mark M.
nope, doesn't ring a bell
but, speaking of bells, it's time for this evening's chat to draw to a close
George S.
Ya.. ansca mobile puts it out.
NetApex
Ha! keepvid.com
Aww dang
George S.
ah.. okay, thanks for your help.
NetApex
lol, ok man.. thanks for the info as usual!
George S.
good night all.
Mark M.
goodnight!
George S.
has left the room
NetApex
has left the room
Mark M.
turned off guest access

Thursday, March 25

 

Office Hours

People in this transcript

  • George S.
  • Mark Murphy
  • NetApex
  • Svetlin Stanchev