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!
|
Mark M. |
how can I help you today?
|
Venelin T. |
Hi, Mark
|
Venelin T. |
greetings from Bulgaria
|
Venelin T. |
and thank you for the great book!
|
Mark M. |
you are very welcome
|
Krishna A. | has entered the room |
Mark M. |
hello, Krishna!
|
Mark M. |
Venelin: do you have a question?
|
Krishna A. |
Hi Mark and Venelin
|
Krishna A. |
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
|
Oct 29 | 10:05 AM |
Mark M. |
Krishna: hold on, let me take Venelin's question first
|
Krishna A. |
sure
|
Venelin T. |
View paste
|
Venelin T. |
sorry if it is too long
|
Mark M. |
well, I would imagine that most "real life apps" are using their own servers
|
Mark M. |
whether those are physical hardware or virtual private servers will vary
|
Mark M. |
apps that wish to use something like Amazon S3 can do so, but your point about API keys is certainly a potential issue
|
Mark M. |
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?
|
Mark M. |
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)
|
Oct 29 | 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
|
Mark M. |
that's how I distribute the book
|
Mark M. |
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
|
Mark M. |
let me take questions from the others, and I will be back with you shortly
|
Mark M. |
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?
|
Mark M. |
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
|
Krishna A. |
yes
|
Krishna A. |
it is just network I/O
|
Oct 29 | 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.
|
Krishna A. |
Thank you
|
Krishna A. |
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
|
Mark M. |
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
|
Mark M. |
AsyncTask is fine for cheap, "disposable" network I/O, where if your process is terminated, you don't care
|
Mark M. |
e.g., avatar images for a ListView for your Twitter client
|
Mark M. |
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
|
Mark M. |
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
|
Mark M. |
for example, I cannot give you legal advice, as I am not a lawyer
|
Mark M. |
and there are strict rules about those sorts of things
|
Bob R. |
understood. I have a lawier for that
|
Oct 29 | 10:20 AM |
Mark M. |
generally speaking, copyright only comes into play when you are actually copying
|
Mark M. |
that's why open source code has licenses attached, granting you permission to do that copying
|
Mark M. |
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)
|
Mark M. |
and all the class header comments indicate this as well
|
Mark M. |
so, if you are literally copying and pasting code, you need to know the license under which that code is made available
|
Mark M. |
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
|
Mark M. |
research != copying
|
Mark M. |
reading != copying
|
Mark M. |
copying == copying
|
Mark M. |
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
|
Mark M. |
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.
|
Oct 29 | 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
|
Mark M. |
let me take questions from the others, and I will be back with you shortly
|
Mark M. |
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...
|
Venelin T. |
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
|
Mark M. |
I'd go with "unless there is a clear reason not to:
|
Mark M. |
er, to"
|
Mark M. |
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
|
Oct 29 | 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
|
Mark M. |
that's a general Java pattern, more so than something unique to Android
|
Mark M. |
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
|
Oct 29 | 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
|
Krishna A. |
than*
|
Mark M. |
make sure that your threads do not run forever
|
Krishna A. |
sure. Thank you :)
|
Krishna A. |
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
|
Oct 29 | 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
|
Mark M. |
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
|
Venelin T. |
if I'm not mistaken
|
Mark M. |
what is "them"?
|
Venelin T. |
the credentials
|
Mark M. |
the credentials will be on your server
|
Mark M. |
your app will have no AWS-related code at all
|
Mark M. |
the pre-signed URL is just a URL, which your app would use to download the ZIP file
|
Mark M. |
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
|
Mark M. |
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!"
|
Oct 29 | 10:45 AM |
Mark M. |
let me take a question from Guarav, and I'll try to get back to you in a bit
|
Mark M. |
Guarav: do you have a question?
|
Venelin T. |
thank you Mark
|
Gaurav B. |
I wanted to know more details about Lazylist
|
Gaurav B. |
means.. i was downloading images from server..
|
Gaurav B. |
and there are more than 500 images..
|
Gaurav B. |
but i will be downloading as the User scrolls down
|
Gaurav B. |
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
|
Gaurav B. |
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
|
Mark M. |
I also demonstrate the use of SmartImageView for obtaining thumbnail images from the MediaStore
|
Gaurav B. |
ohh ok thanks
|
Gaurav B. |
i will go through that
|
Gaurav B. |
i did not research that much
|
Mark M. |
the Picasso coverage is in the Internet chapter
|
Mark M. |
the SmartImageView coverage is in the MediaStore chapter
|
Mark M. |
Bob: do you have another question?
|
Gaurav B. |
thanks mark.. Appreciate your help
|
Oct 29 | 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
|
Venelin T. |
I have S3 service activated - can I call this a server
|
Mark M. |
I do not know what "S3 service activated" means
|
Mark M. |
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
|
Venelin T. |
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
|
Mark M. |
whether you use Amazon EC2 for that, or some other solution (Google App Engine, Linode, whatever), is up to you
|
Mark M. |
again, I would research to see if somebody has already solved this problem
|
Mark M. |
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
|
Oct 29 | 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
|
Venelin T. |
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
|
Mark M. |
the transcript will be published to http://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Thursday, 7:30pm Eastern
|
Mark M. |
have a pleasant day!
|
Mark M. | turned off guest access |