Office Hours — Today, July 13

Thursday, July 8

Jul 13
8:20 PM
Mark M.
has entered the room
Mark M.
turned on guest access
Russ
has entered the room
Mark M.
sorry about that
Russ
Hi Mark
It's ok!
Mark M.
been one of those days...
Russ
Am I really the only one here?
I don't believe it
Mark M.
well, the room just opened a few seconds ago, due to my screwup
Russ
My first time on campfire
:)
Mark M.
welcome here!
Russ
So I guess I should jump up
and ask my qustions
Mark M.
go right ahead!
Russ
I've prepared them...
First off, I'd like to say thanks for being such a generous person with your time for these chats. You provide a unique service that has true value behind it!
ok enough cheese (but its the truth)...
Mark M.
I do what I can!
Russ
View paste
I know little of networking, but understand client side apps in C and Java a little bit.  A friend of mine does web programming, mainly in .NET, but has some experience with older versions of Java.

We have a project that requires uploading 1-2 MB (images) at a time, in the background.  My thought is to start an async task, but I also read somewhere that a service could be used as well.

If we wanted to use POST to do this uploading to a web server, what parts of Android would you recommend reading up on?
Mark M.
AsyncTask and Service are typically orthognal
you can use them both
Russ
should we?
8:25 PM
Mark M.
If you look at the service-related chapters in The Busy Coder's Guide to Android Development, you will see where I use an AsyncTask with a Service for HTTP operations
in that case, it's a GET, not a POST, but the same concept applies
Russ
ok, he was playing with that tutorial earlier today....
Mark M.
whether or not you should use that pattern will depend a bit on the trigger for the upload
Russ
wanted to make sure it was the right thing to go forward with
Mark M.
is this based on user input, an alarm, or something else?
Russ
we will initiate the upload, and the webserver will confirm
input
Mark M.
a Service with an AsyncTask can work fine for that
Russ
sounds good, we will move forward with that...
another question...
Mark M.
another option is to use an IntentService, which gives you work (in the form of Intents) on a background thread
Russ
Another question is about images from the camera. In the future, android devices will probably have ever-increasing megapixel cameras. We want to limit the maximum image size from a camera. Is there a way scale the images down in Android, and if so, can you recommend a resource to where we can learn more about how to do this?
Mark J.
has entered the room
Russ
ok lets place the 2nd question on hold..
Mark M.
howdy, Mark J!
Russ
which do you think i sbetter
Mark M.
Russ: I'd start with the AsyncTask approach
Russ
Hi Mark M
:)
Mark M.
Russ: let me take a question from Mark J, then we can roll back for your 2nd question
Mark J.
Heya Mark. Chatting from my nexus one.
Russ
sure!
Mark M.
Mark J: got a question? one that's type-able on a soft keyboard, anyway?
(BTW, are you using Campfyre, or the Browser?)
8:30 PM
Mark M.
Mark J: are you out there?
ok, Russ, let me tackle your 2nd question while Mark J tries to get reconnected or whatever...
Russ
okay!
i have plenty of patience
Mark M.
BitmapFactory is what people use for scaling images, AFAIK
haven't had a need to fuss with that myself just yet
Russ
ok
Mark M.
you can load an image in off a file using a BitmapFactory.Options object
there you can control scaling, sub-sampling, etc.
Russ
thanks - I can look into it more now that I know where to look :)
I'd also like to ask about sounds on android devices. I have a couple apps that play sounds, and apparently they don't work on Samsung Moment phones (as well as the Cliq). Turns out, those devices only support 8 Khz sounds, not 16. Am I stuck packaging 8 Khz sounds with all apps? Should I only use 8 Khz sounds (I'm not an audiophile, so I really don't know). Is there a way to down-convert when installed on an app and the device is identified as not supporting 16 Khz?
(last question, BTW)
Mark M.
yeah, you sure pack 'em in, though... :-)
I have no idea regarding down-conversion
Russ
:D
8:35 PM
Mark M.
I am perhaps less of an audiophile than you, so I have no good sense whether 8 KHz will be significantly worse for your users
you could package both and choose based on device model sniffing, I suppose
I don't know how you can tell what's supported more directly
I do simple audio file playback -- haven't used SoundPool or AudioTrack yet
Russ
I have a simple sound players setup as well...didn't know there was a problem until I started getting a lot of one-star ratings for the problem. I may just go with 8 khz and be done with it
Mark M.
what are the sounds for? game effects?
Russ
I'd rather not include multiple sets of audio files, takes too much space
No, just part of an app sounds. But my libs could be used for games, I suppose
I'd like to jump back to the first question, if you don't mind
Mark M.
go ahead
Russ
it's an important one for my friend and I
Mark M.
unless Mark J has returned -- you out there?
Russ
Lost in the Android 'Nexus' ?
Mark M.
I was guessing a really long tunnel :-)
OK, Russ, go ahead
8:40 PM
Kevin M.
has entered the room
Russ
You recommend an async task (Dealing With Threads chapter), Communicating Via the Internet chapters, yes?
Kevin M.
Hello
Russ
hello kevin
Mark M.
Russ: yes
howdy, Kevin!
Kevin M.
Let me know when I can ask a question
Russ
go ahead, i've asked plenty already
;-)
Mark M.
Kevin: Russ has asked a few, and Mark J seems to be having connection issues
so go ahead!
Kevin M.
Ok. I've got an music app that show a notification
When the user selects the notification, it starts a new activity and can cause 2 files to play at the same time
Mark M.
is that your goal?
Kevin M.
Is there any way to show the current music activity?
Mark M.
yes
hold on while I look up the recipe...
Kevin M.
It's actually for podcasts that get downloaded
Mark M.
when you create your Intent for your PendingIntent, call setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP) on the Intent
if your activity is still going, this will take the user back to it
8:45 PM
Mark M.
the activity will receive onNewIntent() instead of onCreate()
8:45 PM
Kevin M.
Great. I was trying to make the 2 activities singleTop
Mark M.
(in case your activity needs to be aware that this all occurred)
yeah, where possible, you're better off using Intent flags -- more fine-grained
you'll see this in Android Programming Tutorials, Tutorial 20
Kevin M.
So I should leave the activities as regular activities then?
Mark M.
yes
no need for special settings in the manifest
Kevin M.
Ok. One other question: I've managed to get a floating window up but am having problems getting touch events to the buttons on that window
Mark M.
what do you mean by "floating window"
?
Kevin M.
I copied some of the mediacontroller window's code. It floats above the activity
Mark J.
Okay sorry, I have returned :P. (Campyre didn't work too well
Mark M.
Mark J: welcome back! I'll be with you momentarily
Kevin M.
What happens is when the user touches the screen, the float control window comes up
Mark J.
Alrighty :)
Kevin M.
I'm overriding dispatchTouchEvent and trying to manipulate the position of the event
8:50 PM
Mark M.
that sounds scary
Russ
:O
Kevin M.
Well, it seems necessary
Mark M.
doubtful
Kevin M.
I've got it mostly working
Mark M.
Kevin M.
Have you managed to do this?
Mark M.
I have some popup panels in this app, and buttons placed in those panels behave normally, without any mods to touch events
Kevin M.
I've got that code
Mark M.
also, MediaController does not override dispatchTouchEvent()
you can see the source code through Google Code Search
package:android MediaController
Kevin M.
It doesn't seem that my buttons are getting clicked
Mark M.
to see how they do theirs
Kevin M.
Ok. I'll take a look at those. Which files?
Mark M.
beats me
I just have the projects bookmarked as things I'd like to make a bit more general-purpose someday
beyond that, it's tough to give you specific advice
8:55 PM
Kevin M.
It was kind of interesting. I created a Dialog and got the window from that class as it doesn't seem like you can create a window
Mark M.
see PopupWindow, though I haven't tried that yet
I tend to embed them just in the layout, making them VISIBLE or GONE as needed
Kevin M.
Didn't even know that existed!
Mark M.
OK...Mark J -- you still with us?
Mark J.
Yes :)
Mark M.
got a question?
Mark J.
Yep :)
Russ
nexus keyboards are slooooow.... ;)
Mark J.
Its not as complex as the last ones; I have an ArrayAdapter in a list, and I am able to make new entries into it. But how am I able to Save the information from the list, so that if I restart the activity, the old information is still there
Sorry, Not on my Nexus anymore :P
Mark M.
what scenario(s) are you considering "restart the activity"?
user presses BACK?
user rotates the screen?
user drops phone, battery pops out?
other?
Mark J.
All :)
Mark M.
I'd get rid of the ArrayAdapter and move your data into a persistent store, probably a SQLite database
Mark J.
How can I save the ArrayAdapter/Arraylist
Well, just for more detail. Its just a basic checklist
9:00 PM
Mark J.
Or atleast what I am trying for
Mark M.
that really sounds like a SQLite database
columns for name and checked/not-checked state
plus the obligatory _id column for CursorAdapter
Mark J.
Okay, book section I should refer to?
Mark M.
you'll see how I move an application from an ArrayAdapter to a CursorAdapter and database in Android Programming Tutorials
Tutorial 11, specifically
Mark J.
In APT?
Mark M.
general database usage is covered in the Database chapter of The Busy Coder's Guide to Android Development
Tutorial 11 is in Android Programming Tutorials, yes
Mark J.
Okay
Thanks man. I will check them out
That answers my question
Russ
One last one from me?
Mark M.
go ahead
Russ
I keep getting emails from people who want me to sell my apps on their sites. I haven't responded to any of them and wanted to get your thoughts on this.
Mark M.
well, you'd want to research how good their reach is, to see if it's worth the hassle
Google 'em and see what turns up
Russ
i thought we could only sell apps on the market
Mark M.
on the whole, I have not heard of any independent market that is doing great business
oh, no
you can sell them anywhere
SHOP4APPS (Motorola), AndAppStore, etc.
Russ
but users have to check install non-market apks then, correct?
Mark M.
yes
which means AT&T users are kinda hosed
9:05 PM
Russ
thanks, then answers my questions - you've been a big help today - thanks alot
Mark M.
that's why I'm here
Russ
:)
Kevin M.
Thank you too!
Mark M.
OK, I'm going to wrap this up for the evening
Russ
Take care
Mark M.
(or whatever appropriate time of day it is for wherever you are)
see you later!
Russ
8:05 AM :)
Mark J.
6:05PM :)
Russ
has left the room
Mark J.
has left the room
Kevin M.
has left the room
Mark M.
turned off guest access

Thursday, July 8

 

Office Hours

People in this transcript

  • Kevin Moroe
  • Mark Johnston
  • Mark Murphy
  • Russ