Office Hours — Today, June 15

Thursday, June 10

Jun 15
7:45 PM
Mark M.
has entered the room
7:55 PM
Mark M.
turned on guest access
8:00 PM
Jim
has entered the room
Mark M.
howdy, Jim!
Jim
Hello Mark. Got time for a question ?
Mark M.
that's why I'm here!
fire away!
Jim
First let me send you the stack trace.
View paste
06-14 22:07:13.544: WARN/System.err(26363): java.io.IOException: Parent directory of file does not exist: /sdcard/appname/photo.jpg13028jpg
06-14 22:07:13.551: WARN/System.err(26363):     at java.io.File.createNewFile(File.java:1263)
06-14 22:07:13.559: WARN/System.err(26363):     at java.io.File.createTempFile(File.java:1330)
Now the code.
View paste (18 more lines)
ContentValues values = new ContentValues();
		values.put(MediaStore.Images.ImageColumns.DISPLAY_NAME, fileName);
		values.put(MediaStore.Images.ImageColumns.MIME_TYPE, "image/jpeg");
		parent.getContentResolver().insert(
				MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

		File parentDir = Environment.getExternalStorageDirectory();
		File dir = new File("/" + parentDir.getName() + "/appname");
		if (!dir.exists())
			dir.mkdir();
		File photo = null;
		try
		{
			photo = File.createTempFile(fileName, "jpg", dir);
		}
...
It pops off on the createTempFile line.
I am trying to save a camera picture.
Mark M.
Your mkdir() call probably returned false
Jim
Could there be a permissions problem ?
Mark M.
perhaps the SD card is unavailable (not installed, mounted on a host PC, etc.)
you do need the WRITE_EXTERNAL_STORAGE permission, starting with Android 1.6
Kevin M.
has entered the room
Jim
I used a Motorolla Droid.
Running 2.1
Mark M.
That'll be 2.0 or 2.1
Kevin M.
Hello
Julius
has entered the room
Mark M.
right
howdy, Kevin & Julius!
Jim
Ok. Let me give a try.
Mark M.
remember: either the DROID can have the SD card, or the host PC can have the SD card, but not both at once
8:05 PM
Julius
hiya
Kevin M.
Looks like you're helping someone. Let me know when you're done
Mark M.
Jim: you might try calling Environment.getExternalStorageState() to see what is being reported
OK...Kevin, you're next -- got a question?
Jim
Yall go ahead while I try Mark's suggestion.
Kevin M.
Sure. I'm trying to write a custom layout class
I'm having problems reading in the attributes from an xml file
Mark M.
what sorts of problems?
Kevin M.
It doesn't have the attributes I specify in the xml file
The layout is defined in another project. Not sure if that is the problem
Mark M.
that certainly complicates matters
I would recommend you check out the Reusable Components chapter of _The Busy Coder's Guide to Advanced Android Development_
Julius
(ah that answers a question I had... better read that)
Mark M.
and take a look at the CWAC-ColorMixer project: http://github.com/commonsguy/cwac-colormixer
while not a custom layout class, these do illustrate how to create a custom View in one project and reuse it in another
Kevin M.
I'll take a look at it. I referenced the file by using a custom xmlns in the xml file
Mark M.
is the attrs.xml from the layout class also copied over into the reusing project's resources?
Kevin M.
I think I got the right syntax as it didn't complain but I never got the values set
Mike R.
has entered the room
8:10 PM
Mike R.
Hello
Mark M.
howdy, Mike R -- you're in line behind Kevin (working on a question now) and Julius
Kevin M.
No, I didn't copy it over
Mark M.
Kevin: that's at least part of your problem
Kevin M.
OK. Very confusing
Mark M.
yes, it took me a fair amount of fussing to get a recipe that works
Kevin M.
If there was some sample code, that would help alot
Mark M.
with respect to layouts, I can't help you there
Kevin M.
Good news is that the layout works well programmatically
Mark M.
with respect to attribute handling, that's in the Custom Views and Reusable Components chapters of the Advanced Android book
Kevin M.
Ok. I'll take a look at it
Mark M.
well, heck, getting the layout to work is the hard part, from my standpoint, so you're in pretty good shape
I tried writing one once and surrendered
Kevin M.
It's a GridLayout with resizable columns and rows
Mark M.
That's cool
Kevin M.
Very cool. I don't have to recreate the layout when I rotate the screen
Mark M.
OK...Julius, got a question?
Julius
just wondering about file format and whether it's possible to query them
so say I have some media
like mp4 mp3 etc.
Jeffrey B.
has entered the room
Julius
is there a way to find out whether the media type is supported
Mark M.
I don't know of a way to do that, unfortunately
Julius
oops
Mark M.
howdy, Jeffrey -- you're in line behind Julius (working on a question now) and Mike
8:15 PM
Julius
anywho it asically said some platforms "may" support some file types
Mark M.
Julius: right, that's the list of possible ones
Julius
no worries I won't hold you up
Mark M.
right
Julius
thanks for the time
Mark M.
most will support what is in there
some may support WMA/WMV in addition
I don't know of any device that supports less than that list
Julius
(I might lurk just to read)
oh ok good ot know
Mark M.
mostly because the support for all that is free and in the open source tree
OK...Mike, got a question?
Mike R.
yeah. you already started to answer it on stack overflow
it's about webview
trying to get it to work with Google AdManager
Mark M.
got a link to the SO question?
Joey D.
has entered the room
Mike R.
so, I'm loading a HTML string which calls a lot of javascript that eventually displays an image that hyperlinks back to ad manager
the image loads fine and onPageCompleted gets called.
when the user taps on the image, instead of shouldLoadUrl being called, onLoadResource is called.
I need shouldLoadUrl so that I can intercept and invoke the full web browser.
Mark M.
Hmmmm...is it loading in some Javascript, perhaps?
Mike R.
oh yes, it's all javascript
Mark M.
and the URL passed to onLoadResource() is a path to a Javascript file being loaded?
8:20 PM
Mike R.
actually, there are a couple of calls. One or two call back to Doubleclick, but the last one is a call to the advertiser
Mark M.
...and the URL passed to onLoadResource() is a path to a Javascript file being loaded?
basically, I'm trying to understand why it is onLoadResource() -- that should be for images, Javascript, etc.
if the HTML is set up that clicking the image is loading Javascript rather than loading a Web page, I don't think there's much you can do, other than to rewrite the Javascript/HTML to not do that
Mike R.
that call is still included in the onLoadResource() calls.
for instance, http://www.apple.com in my example.
Mark J.
has entered the room
Mark J.
Hello
Mark M.
Quick update: howdy, Joey and Mark -- you are behind Jeffrey, who is behind Mike, who is being helped right now
Mike R.
Surely, someone has AdManager working on an Android device?
this is all requirements from AdManager
Mark M.
Mike: well, I haven't played with AdManager anywhere, let alone on Android
Joey D.
Thanks for the update.
Mark M.
are you trying to use desktop browser stuff, or the new mobile stuff?
8:25 PM
Mike R.
what new mobile stuff?
Mark M.
Ummm...AdSense for Mobile, I think it's called
since I have never used AdSense, I don't know what level of control you have over sources of inventory, etc. -- all of that is well outside the scope of this chat session
Mike R.
i'm not sure that applies to us. we're using admanager to server up our own ads, not to get third party ads to display in our ap.
Mark M.
I don't really know what to tell you
Mike R.
ok. i'll keep looking
Mark M.
I really doubt Android is mistakenly calling onLoadResource()
Mike R.
well the url in onLoadResource() is http://www.apple.com
Mark M.
OK...Jeffrey, got a question?
Jeffrey B.
Hi yes... Is it possible to reduce the sensitivity of the microphone?
Mark M.
cover it with a cotton ball?
:-)
Jeffrey B.
lol alread thought of that
Mark M.
I haven't played with audio recording, so I am not familiar with the options here -- sorry
Jeffrey B.
OK... Thanks.
I'll look further.
Mark M.
Ummmm...Joey, do you have a question?
8:30 PM
Joey D.
I am stuck on streaming audio
I can get an MP3 to play via URL
but when I try to open an aac+ file with mediaplayer, I get errors that don't seem to have a definition
error(1, -10_
error(1, -10)
Mark M.
yeah, those are being spit out by the Packet Video OpenCORE code
the error tag probably starts with PV
Joey D.
yes
Mark M.
unfortunately, most of that stuff is very undocumented
Joey D.
PVMF
Mark M.
does the file work if you download it and play it locally?
also, is the HTTP or RTSP?
Joey D.
it works on iphone...
http
Mark M.
er, is the protocol HTTP or RTSP?
Joey D.
got it. it's http
Mark M.
I would try the file locally -- if it fails, it is an encoding issue
if it succeeds...perhaps Android can't stream AAC+ over HTTP for some reason
Joey D.
lots of apps do it, or claim to do it
Mark M.
the boundaries of what MediaPlayer all supports, particularly in terms of streaming, is tough to decipher
Joey D.
i've been messing around with caching it locally and opening it with a mp3 wrapper
but I get a second problem (this one will be easy!)
i add WRITE_EXTERNAL_STORAGE to my manifest, but the permission never shows up
8:35 PM
Joey D.
so I can't write to the cache file
INTERNET works fine
Mark M.
here is one that works:
Joey D.
I'm targeting an N1 device for testing
Mark M.
there is probably something syntactically off with your permission in the manifest
the permission definitely works on an N1
OK...Mark, got a question?
Mark J.
Heya, it is my first time hopping in here, so I just wanted to say hello. Also I wanted to know if if code related questions are allowed.
Mark M.
so long as it is related to Android development, it's fair game
Mark J.
Alright cool it is :)
Mark M.
though depending on how involved it is, I may or may not be able to answer...
Mark J.
Well, I have a tab widget with many different tabs, and they have become very cramped
I am looking to see how it is possibly to maybe horizontally scroll through them
possible*
Mark M.
oy
8:40 PM
Mark M.
I haven't tried wrapping a TabWidget in a HorizontalScrollView, so I don't know if that works
if not, you'd probably have to subclass/rewrite TabWidget, based on the open source code, which probably is not going to be a ton of fun
Kevin M.
has left the room
Mark M.
are you sure you are not better off splitting some of that into other activities?
Mark J.
Hmm, well, what I was aiming for,
Have you played with maybe, the Engadget app? or the AndroidGuys app?
Mark M.
neither (though don't tell AndroidGuys that)
Mark J.
:P That's okay
Alright, well since you have others to help, I will just let you move on, as I will keep looking. By the way, just bought the books yesterday and love them :) Thanks
Mark M.
downloading the AG app now
Julius
hi - sorry to butt in - I am expecting to have the same problem and read here that there maybe a solution for this at some point.
Mark M.
from the screenshots, I'm not sure that's actually tabs, in terms of TabHost/TabWidget
Julius
(in the second picture in "pattern 5:"
Mark J.
The "Tweets" and "People"?
Mark M.
right
Julius
(no idea how to do it, but it might allow for more selection options in a way)
Mark M.
that too is not TabHost/TabWidget, but something else
Mike R.
has left the room
8:45 PM
Julius
for sure - just a problem I'm expecting to face soon and hoping this will help
oh no the next piture
Mark M.
yeah, I am eagerly awaiting the Twitter open source release
Julius
there are two next to each other and the one on the left
just under that one
(me too :))
Mark M.
Going back to the AG app, they are probably using ViewFlipper for the body and something custom for the tabs
probably a LinearLayout of tabs, in a HorizontalScrollView, bracketed by ImageButtons
Mark J.
Alright, I will give something like this a shot :)
Thanks man.
Mark M.
it's for stuff like that why I am trying to encourage code reuse, because we need more stuff like it available for all developers, without everyone reinventing the wheel
anyway...back to the top...
Jim: got another question?
Jim
Nope. You rock. It was the permission.
Mark M.
Great!
Julius: got another question?
Julius
no I'm good thankyou
Mark M.
Jeffrey: got another question?
OK, *anybody* have another question?
8:50 PM
Joey D.
i do
Mark M.
go ahead
Joey D.
perhaps I am not seeing it anywhere, but there isn't a lot of discussion about coming from an MVC paradigm to android
it seems to me that android mingles view and controller functionality quite a bit
Jeffrey B.
has left the room
Joey D.
I would think that it would be discussed ad naseaum, but I can't find anyone talking about it, or addressing it in any way
Mark M.
I tend to think of the widgets as being the view, the Cursor (and helper classes) as being the model, and the activity as being the presenter/controller
but, you're right, MVC is not something Google emphasizes
in part, because a lot of MVC frameworks focus on thick models
and Android tries to minimize data copying, object creation, etc.
Joey D.
what does "thick model" mean?
Mark M.
a thick (or rich or whatever) model would be a model class (e.g., Person)
if you did a query on a 'person' table, you'd copy the data out of the Cursor into a bunch of Person objects
Joey D.
ok
Mark M.
and Person would have some amount of business logic
that's cool when you have gobs of RAM
less cool when you have drips and drops of RAM, and a slow CPU to boot
8:55 PM
Mark M.
someday, when there's more elbow room, you'll see more emphasis on ORMs and the like
right now, when resources are limited, coding for structural cleanliness takes a back seat to optimization and performance
rightly or wrongly
OK, we're running low on time...any other questions?
Joey D.
thanks
Julius
I tend to have my model classes set up with constants like field names and table name in them etc.
is that a bad way to go?
Mark M.
well, constants (static final) are a generally good thing
Julius
yeah just so my dbHelper can use them...
ok
Jim
Any api to compress a jpeg before I send to a servlet ?
Julius
has left the room
Mark M.
yeah, I think there something for that...
Jim
In your books ?
Mark M.
yeah, there's a compress() method on Bitmap
no, not in the books
Jim
Ok. Thanks. Have a good evening.
Mark J.
I have one, sort of. What is your position currently in Android Development?
Jim
Huh ?
Mark M.
Well, I'm sitting down right now
9:00 PM
Mark M.
:-)
Mark J.
Sorry, I meant for Mark
Jim
has left the room
Mark M.
Could you be a bit more specific?
Mark J.
Well, I mean, what are some of your projects? Or what interests you most specifically?
Mark M.
that's kinda a complex question
Mark J.
Sorry :( We can just drop it :)
Mark M.
my "projects" that I can talk about are my books, promoting reuse via the Android Parcel Project, and so forth
Mark J.
Okay, also are you the only one that answers questions here?
Mark M.
Well, my vast army of dust bunnies is presently on strike, due to unsafe work conditions (a.k.a, vacuum cleaner)
Otherwise, CommonsWare is just little ol` me
Mark J.
Haha, alright
Mark M.
anyway, that's a wrap for tonight's chat
Mark J.
Well I love the it man, it think it is great, and I love the books, I am currently still reading them through Aldiko. Seeya next time
Mark M.
Thursday's chat will be at the same time, rather than the usual morning slot, since I am teaching a course this week
Mark: thanks!
have a pleasant evening!
Joey D.
has left the room
Mark J.
has left the room
Mark M.
turned off guest access

Thursday, June 10

 

Office Hours

People in this transcript

  • Jeffrey Bertoia
  • Jim
  • Joey Dempster
  • Julius
  • Kevin Moroe
  • Mark Johnston
  • Mark Murphy
  • Mike Renda