Office Hours — Today, October 29

Friday, October 18

Mark M.
has entered the room
Mark M.
turned on guest access
Oct 29
10:00 AM
Venelin T.
has entered the room
Mark M.
hello, Venelin!
how can I help you today?
Venelin T.
Hi, Mark
greetings from Bulgaria
and thank you for the great book!
Mark M.
you are very welcome
Krishna A.
has entered the room
Mark M.
hello, Krishna!
Venelin: do you have a question?
Krishna A.
Hi Mark and Venelin
yes I do have a general Android question.
Venelin T.
yes Mark, I'm typing it
Krishna A.
I am trying to find my stackoverflow one
10:05 AM
Mark M.
Krishna: hold on, let me take Venelin's question first
Krishna A.
sure
Venelin T.
View paste
I'm working on an android app that needs to use cloud storage for some resource files which should be downloaded
only upon user's request.

The knoweledge I have so far (I'm still beginner in Java, Android and programming in general)
leads me to Amazon AWS S3 service which I've applied successfully.

To avoid some negatives of hard coding the Amazon's credentials I need to use Token Vending Machine 
which seems quite complicated (probably too much for my app anyway) and this required to deploy my own server.
I find that Amazon documentation is rather confusing from beginner's point of view and I'm not sure if this is the right way to do it.

Could you advice what real life apps are using to handle the storage and tha access of resources that needs
to be loaded upon user's request.
sorry if it is too long
Mark M.
well, I would imagine that most "real life apps" are using their own servers
whether those are physical hardware or virtual private servers will vary
apps that wish to use something like Amazon S3 can do so, but your point about API keys is certainly a potential issue
I have not looked at Token Vending Machine and so am not familiar with it
Bob R.
has entered the room
Mark M.
what is the nature of these "resource files"?
Bob R.
Hi
Mark M.
(hello, Bob -- I will be with you shortly, after Venelin and Krishna!)
Venelin T.
zip of audio files
Mark M.
is it the same ZIP for all users? or a ZIP per user?
IOW, is the content unique per user, or do all users get the same content?
Venelin T.
it will be zip for all users who has access to it (via in-app purchases)
Mark M.
I would consider using APK expansion files, where you only use the content if the user has purchased it: http://developer.android.com/google/play/expans...
Venelin T.
all get the same content (if they have access to it)
10:10 AM
Mark M.
or, use a simplified version of the Token Vending Machine, where your own server code returns a short-lived pre-authorized URL from Amazon S3
that's how I distribute the book
but, since I have not used in-app purchasing APIs, I am short on the details for how your server would know what requests for such a pre-authorized URL are valid
let me take questions from the others, and I will be back with you shortly
Krishna: do you have a question?
Krishna A.
Yes
Venelin T.
sure, thank you
Krishna A.
I posted it on Stackoverflow. Can I put the link here?
Mark M.
sure
Krishna A.
Mark M.
how long will it take for the work you are trying to do in the background to run?
is it just the network I/O to download the image?
Krishna A.
it may be very quick but in some scenarios it has to download background images and may take a few seconds
yes
it is just network I/O
10:15 AM
Mark M.
personally, I would recommend replacing your own code with an existing third-party library for it, like Picasso or SmartImageView, as described in the book
Krishna A.
Sure, I will look into both of them.
Thank you
but in this case is it ok to update the UI when the activity is not in foreground?
Mark M.
that being said, there should be no problem in updating the activity from onPostExecute(), even if the activity is not in the foreground
Krishna A.
awesome. Thank you
Mark M.
if the activity is finished, your widgets still exist, but the work you do will be ignored
if, however, you need this I/O to succeed, beyond simply loading the image for the user to see, for something that may take multiple seconds, you probably should switch to an IntentService
AsyncTask is fine for cheap, "disposable" network I/O, where if your process is terminated, you don't care
e.g., avatar images for a ListView for your Twitter client
but once you no longer have an activity in the foreground (e.g., user presses HOME rather than launching another of your activities), Android can terminate your process at any point
Krishna A.
yes, Thank you. I already switched them to normal threads as that is so quick but IntentService is good too
Mark M.
OK
Krishna A.
Thank you again
Mark M.
let me take questions from the others, and I will be back with you shortly
Bob: do you have a question?
Bob R.
Regarding the copyright stuff I was able to send a email to Brian Phillips (author of the book I was using). With all the material out there, how do you make sure your new app doesn't run into any copyright issues? Also I posted a question on Stack Overflow. When you have a reputation of less than 25 your under strict guidelines. The questions are scrutinized.
Mark M.
well, copyright is not really on-topic for this chat
for example, I cannot give you legal advice, as I am not a lawyer
and there are strict rules about those sorts of things
Bob R.
understood. I have a lawier for that
10:20 AM
Mark M.
generally speaking, copyright only comes into play when you are actually copying
that's why open source code has licenses attached, granting you permission to do that copying
and that's why all my book samples are specifically in a GitHub repository flagged to be licensed under an open source license (Apache License 2.0)
and all the class header comments indicate this as well
so, if you are literally copying and pasting code, you need to know the license under which that code is made available
and if you cannot determine the license, don't copy it
Bob R.
I guess the real question is when you have an idea, don't you research for examples etc that perform the tasks you want to work efficiently?
Mark M.
sure
research != copying
reading != copying
copying == copying
Ctrl-C / Ctrl-V ~= copying
Bob R.
I read the material and copied routines under my own names (fields etc) and got the app to work.
Mark M.
and therefore you are subject to whatever license terms those "copied routines" are published under
if you cannot find the license, or you do not wish to agree with those license terms, do not copy those "routines"
Bob R.
So if I copy the basic design and have all the field names etc under my own syntax, thats not really copying.
10:25 AM
Mark M.
that's getting into stuff you would need to discuss with your lawyer, as I have no idea what "basic design" is
let me take questions from the others, and I will be back with you shortly
Venelin: do you have another question?
Venelin T.
yes
Bob R.
OK Mark, thanks for your help. When I began looking at publishing I really got confused. Sorry
Venelin T.
I've notice in your book that you call the super before doing something else in onCreate, onResume...
but onStop, onPause, onDestroy you're calling in it last, after the rest of the code
Mark M.
correct
Venelin T.
is that how it should be done always?
Mark M.
well, "always" is a little strong
I'd go with "unless there is a clear reason not to:
er, to"
generally speaking, if the method has clear "creation" semantics, you chain to the superclass first, so if you try using an inherited method, the superclass' initialization will have been done
10:30 AM
Mark M.
similarly, if the method has clear "destruction" semantics, you chain to the superclass last, so if you try calling an inherited method, you do not accidentally use something that the superclass disabled
Venelin T.
it's becoming clear now
Mark M.
and for methods that are not necessarily one or the other (e.g., onSaveInstanceState()), ideally the order does not matter
that's a general Java pattern, more so than something unique to Android
it just so happens that we tend to need to chain to the superclass a lot, in lifecycle methods
Venelin T.
I see
Mark M.
let me take questions from the others, and I will be back with you shortly
Venelin T.
I have another Q, just to clarify my first Q
Mark M.
Krishna: do you have a question?
Krishna A.
Yes, something related to my previous one but Venelin seems to have a question
Venelin T.
it's ok, go ahead
Krishna A.
You said "if the activity is finished, your widgets still exist, but the work you do will be ignored". Is that something I have to worry about because I am causing all my views to sit there waiting for the listeners?
Mark M.
well, if your AsyncTask is capable of talking to your activity, the activity cannot be garbage collected until the AsyncTask completes
Krishna A.
I am using the onAttachedToWindow and onDetachedFromWindow methods to register and unregister the listeners just to be safe
Mark M.
that seems like overkill
10:35 AM
Mark M.
just make sure that your AsyncTask does not run forever
Krishna A.
I am using normal threads. I am not sure it the behaviour is any different tan using AsyncTasks
than*
Mark M.
make sure that your threads do not run forever
Krishna A.
sure. Thank you :)
Great knowing that and answering my questions.
Mark M.
you are very welcome
Krishna A.
thank you for answering my questions*
Mark M.
Bob: do you have another question?
Krishna A.
has left the room
Mark M.
OK, Venelin: do you have another question?
Venelin T.
View paste
You've answered: "... use a simplified version of the Token Vending Machine, where your own server code returns a short-lived pre-authorized URL from Amazon S3
that's how I distribute the book..."
10:40 AM
Venelin T.
is that the same as if I use 'generatePresignedUrl'?
Gaurav B.
has entered the room
Mark M.
ah, yes, "pre-signed" is how AWS refers to it
Gaurav B.
Hello Everybody
Mark M.
sorry, I forgot their terminology
Venelin T.
that I'm using now
Mark M.
(hello, Gaurav -- I will be with you shortly!)
Gaurav B.
yes sure. Thanks
Mark M.
Venelin: if your server is the one generating the pre-signed URLs, then your AWS API keys will be on your server
your server would need to validate that a request from your client is valid (i.e., it is tied to a completed in-app purchase)
Venelin T.
but I think I still need to hard code them and pass them to the S3Client
if I'm not mistaken
Mark M.
what is "them"?
Venelin T.
the credentials
Mark M.
the credentials will be on your server
your app will have no AWS-related code at all
the pre-signed URL is just a URL, which your app would use to download the ZIP file
now, it is possible that there is some existing service that ties into Google Play in-app purchases and makes it easy for you to securely distribute content for those purchases
Venelin T.
basically, the server is generating the presigned url
Mark M.
as I do not use in-app purchases, I have not researched this
correct, the server is generating the pre-signed URL, based upon an HTTP request from the app saying "yo! I need the URL to download this resource that I purchased using this in-app purchase!"
10:45 AM
Mark M.
let me take a question from Guarav, and I'll try to get back to you in a bit
Guarav: do you have a question?
Venelin T.
thank you Mark
Gaurav B.
I wanted to know more details about Lazylist
means.. i was downloading images from server..
and there are more than 500 images..
but i will be downloading as the User scrolls down
so.. do you think just using the adapter view.. is the optimal way to do it.. by just calling the web service at the scrolling down request
or should i go for the lazy list
Mark M.
in the book, I demonstrate the use of Picasso for downloading images in the background from a server
I also demonstrate the use of SmartImageView for obtaining thumbnail images from the MediaStore
Gaurav B.
ohh ok thanks
i will go through that
i did not research that much
Mark M.
the Picasso coverage is in the Internet chapter
the SmartImageView coverage is in the MediaStore chapter
Bob: do you have another question?
Gaurav B.
thanks mark.. Appreciate your help
10:50 AM
Mark M.
Guarav: you are very welcome
Bob R.
has left the room
Mark M.
Venelin: do you have another question?
Venelin T.
probably a stupid one, sorry for that, but Amazon AWS is still difficult for me to grasp
I have S3 service activated - can I call this a server
Mark M.
I do not know what "S3 service activated" means
that being said, Amazon S3 is definitely running on servers, plural
Venelin T.
I mean if I want to connect my app with the servers, do I need some other AWS service to deploy apart S3
in case to generatePresignedUrl
Mark M.
well, again, if you do not want your AWS credentials on the device, then you will need *your own server* as an intermediary
whether you use Amazon EC2 for that, or some other solution (Google App Engine, Linode, whatever), is up to you
again, I would research to see if somebody has already solved this problem
there may be services out there designed to securely distribute in-app purchased content to your users
Venelin T.
I understood now
Mark M.
I just have zero interest in this space, so I am not aware of any
10:55 AM
Mark M.
OK, only a few minutes left, so if either of you have questions, feel free to chime in
Venelin T.
sure, you point me where to look for more info
Thank you Mark, appreciate it
Mark M.
happy to be useful!
Venelin T.
has left the room
Gaurav B.
has left the room
Mark M.
OK, that's a wrap for today's chat
the transcript will be published to http://commonsware.com/office-hours/ shortly
the next chat is Thursday, 7:30pm Eastern
have a pleasant day!
Mark M.
turned off guest access

Friday, October 18

 

Office Hours

People in this transcript

  • Bob Richardson
  • Gaurav Bhatnagar
  • Krishna Achanta
  • Mark Murphy
  • Venelin Tanev