Mark M. | has entered the room |
Mark M. | turned on guest access |
Chandra S. | has entered the room |
Chandra S. |
Hi Mark
|
Mark M. |
hello, Chandra!
|
Mark M. |
how can I help you today?
|
Chandra S. |
How to implement a download function of a big files (such as 50 MB). Is the Loader function enough?
|
Mark M. |
IMHO, no
|
Chandra S. |
If the download stopped before it finished, can we resume again?
|
Mark M. |
that would depend on your HTTP API and whether it supports some sort of resume functionality
|
Mark M. |
for larger files like that, I would recommend using an IntentService, so your process is unlikely to be terminated while the download is in progress
|
Chandra S. |
That's also my confusion.. About Loader and IntentService difference
|
Oct 22 | 9:00 AM |
Chandra S. |
Who is getting more time in the lifecycle?
|
Oct 22 | 9:00 AM |
Mark M. |
I do not know what "getting more time in the lifecycle" means, sorry
|
Chandra S. |
If it required let say 1 hour to download the file, will the Loader or IntentService will stay if user close the foreground?
|
Mark M. |
the Loader will not
|
Mark M. |
mostly because the activity will be destroyed *long* before the hour is up
|
Mark M. |
"if user close the foreground" might directly destroy the activity (BACK) or simply cause the process to be terminated eventually (HOME, RECENTS, etc.)
|
Mark M. |
a Loader is mostly for configuration changes, nothing more
|
Chandra S. |
So if user close the foreground, the loader also will be terminated?
|
Mark M. |
it can be, if the user presses BACK
|
Chandra S. |
Yes I mean that user press back
|
Mark M. |
a Loader should not be doing anything more once its hosting activity is destroyed; otherwise, that is a buggy Loader
|
Chandra S. |
I see.. I thought that it will be remained also
|
Chandra S. |
So in your appinars, are you using the IntentService?
|
Oct 22 | 9:05 AM |
Mark M. |
if you mean is Community Theater downloading appinars via an IntentService, then yes
|
Chandra S. |
I see.. ok2 thanks
|
Chandra S. |
I have another question regarding the app also
|
Chandra S. |
How did you implement search function in the the busy coder app in the Android? Since it's quite fast
|
Mark M. |
I use SQLite and FTS3
|
Mark M. |
there's a chapter on that in the book
|
Mark M. |
when I release an update, I have a Ruby script that generates an FTS3 table in a SQLite database, based on the book contents
|
Mark M. |
that gets packaged as an asset in the APK
|
Mark M. |
I use SQLiteAssetHelper to unpack it at runtime (also covered in the book)
|
Mark M. |
then, your search queries just go against the FTS3 table
|
Chandra S. |
I see.. Thanks, I will read on that one
|
Chandra S. |
I have another question also regarding the storage, what's the difference between internal and phone storage?
|
Mark M. |
I do not know what you consider "phone storage" to be
|
Oct 22 | 9:10 AM |
Mark M. |
Android has internal storage: https://commonsware.com/blog/2014/04/07/storage...
|
Mark M. |
Android has external storage: https://commonsware.com/blog/2014/04/08/storage...
|
Mark M. |
Android has removable storage, at least officially on Android 4.4+: https://commonsware.com/blog/2014/04/09/storage...
|
Mark M. |
I do not know whether you consider "phone storage" to be external storage, removable storage, or something else
|
Chandra S. |
Hmm I just saw it on my phone actually :-D I'll upload it on a moment
|
Chandra S. |
Can we write on all of them?
|
Chandra S. |
Internal, external, and removable
|
Mark M. |
your app can write in your app's designated portion of internal storage
|
Mark M. |
your app can write to external storage, if it holds proper permissions
|
ndrocchietto_ivano | has entered the room |
Mark M. |
you do not have arbitrary access to removable storage on Android 4.4+
|
Mark M. |
this is all covered in the chapter on file I/O in the book
|
Mark M. |
let me take a question from Ivano, and I will be back with you shortly
|
Oct 22 | 9:15 AM |
Mark M. |
Ivano: your turn! do you have a question?
|
Chandra S. |
Ok
|
ndrocchietto_ivano |
ciao Mark, I have a question regarding Mockito setting. I set Mockito as you indicated
|
ndrocchietto_ivano |
but the method of mockito under junit test are not recognized( are red) and i found on SO that the solution is
|
ndrocchietto_ivano |
one sec i am finding it
|
ndrocchietto_ivano |
View paste
|
Mark M. |
um, well, that's what I describe in the book
|
Mark M. |
the section on Mockito is in the chapter on unit tests
|
ndrocchietto_ivano |
mmh
|
Mark M. |
unit tests run on the JVM of your development machine
|
ndrocchietto_ivano |
yes
|
Mark M. |
whereas instrumentation tests run on Android (device/emulator)
|
ndrocchietto_ivano |
yes
|
Mark M. |
so, the Mockito example uses testCompile to pull in Mockito, not androidTestCompile
|
Mark M. |
and the Mockito example has the Mockito-using test cases in test/, not androidTest/
|
ndrocchietto_ivano |
i know that, i used
|
Mark M. |
and to run them, you need to run the unit tests
|
Oct 22 | 9:20 AM |
ndrocchietto_ivano |
View paste
|
ndrocchietto_ivano |
what i do not understand is what means "change test artifact to "unit Tests" in Android Studio(in Build Variant tool window)
|
ndrocchietto_ivano |
is something with flavors?
|
Mark M. |
ah, that part has changed, due to changes in Android Studio
|
Mark M. |
there used to be a drop-down in the Build Variants tool in Android Studio to let you choose whether you were working with the instrumentation tests or unit tests
|
ndrocchietto_ivano |
I see
|
Mark M. |
that is no longer needed
|
ndrocchietto_ivano |
OK thanks
|
Mark M. |
let me take a question from Chandra, and I will be back with you in a bit
|
Mark M. |
Chandra: back to you! do you have another question?
|
ndrocchietto_ivano |
OK
|
Chandra S. |
View paste
|
Chandra S. |
That is in my phone, internal, SD card, and phone storage
|
Mark M. |
you would have to ask your device manufacturer what that means
|
Mark M. |
that is not part of standard Android
|
Chandra S. |
I see
|
Oct 22 | 9:25 AM |
Chandra S. |
I also curious on why Whatsapp can not save images/videos on the SD card
|
Mark M. |
you would have to ask them
|
ndrocchietto_ivano | |
Mark M. |
they could use the Storage Access Framework on Android 4.4+ for that (ACTION_CREATE_DOCUMENT)
|
Chandra S. |
Since I have a plan to build the app that write to storage, so just curious whether there's a restriction
|
Mark M. |
or they could use getExternalFilesDirs()/getExternalCacheDirs() on Android 4.4+
|
Chandra S. |
I see.. Ok thanks I'll check on that
|
Mark M. |
all of that is also covered in the book
|
Mark M. |
let me take another question from Ivano, and I will be back with you afterwards
|
Chandra S. |
Ok
|
Mark M. |
Ivano: back to you! do you have another question?
|
ndrocchietto_ivano |
well yes is simple but you do not manage dagger 2
|
Mark M. |
I have never used Dagger 2, sorry
|
ndrocchietto_ivano |
OK
|
ndrocchietto_ivano |
i have JB
|
ndrocchietto_ivano |
haI hate JB
|
ndrocchietto_ivano |
I hate JB, made my life difficult:(
|
Oct 22 | 9:30 AM |
Mark M. |
it's a little older
|
Mark M. |
the three Jelly Bean versions (4.1/4.2/4.3) are starting to fade out -- ~15% of the Google Play ecosystem at the moment
|
Mark M. |
(plus another ~3% of versions older than that)
|
ndrocchietto_ivano |
sorry
|
ndrocchietto_ivano |
I mean the coder that invented retrofit 1/2 and dagger 1 2 from square
|
Mark M. |
sorry, I don't know who that is
|
ndrocchietto_ivano |
jack wharton
|
Mark M. |
I think you mean Jake Wharton
|
ndrocchietto_ivano |
yep
|
Mark M. |
Dagger 2 is maintained by Google now IIRC, so I do not know how much Jake is involved
|
ndrocchietto_ivano |
ah
|
Mark M. |
anyway, let me take another question from Chandra, and I'll turn back to you in a while
|
Mark M. |
Chandra: back to you! do you have another question?
|
ndrocchietto_ivano |
OK thanks
|
Oct 22 | 9:35 AM |
Chandra S. |
Actually this is a basic question :-D What's the difference of AppCompat, Actionbar, and Toolbar?
|
Mark M. |
well, the action bar is the stripe across the top of your activity that has your activity's title
|
Mark M. |
that was added to Android with API Level 11 (Android 3.0)
|
Mark M. |
in Android 5.0, the refactored the code, creating Toolbar, which gives you an action bar-style widget that you can place wherever you want
|
Mark M. |
the appcompat-v7 library offers a backport of the action bar and Toolbar that works back to API Level 7
|
Mark M. |
if your minSdkVersion is lower than 11, and you want to use an action bar, you should use appcompat-v7
|
Mark M. |
if your minSdkVersion is lower than 21, and you want to use a Toolbar, you should use appcompat-v7
|
Mark M. |
Google's attitude is that you should *always* use appcompat-v7, but I feel that it should be an explicit decision
|
Chandra S. |
I see.. Got it, Mark.. Thanks
|
Mark M. |
the book has chapters on the action bar, on Toolbar, and on AppComapt
|
Mark M. |
er, AppCompat
|
Chandra S. |
What is library that is in the appcompat v21?
|
Mark M. |
there is no appcompat-v21 library that I know of
|
Oct 22 | 9:40 AM |
Mark M. |
I do not see one in my copy of the Android SDK
|
Mark M. |
so, I am not sure what you are referring to
|
Mark M. |
at this point, if either of you have a question, go right ahead and ask
|
ndrocchietto_ivano |
Not really. Kotlin,Testing,Jenkins and ..JW, are taking all the time supposed to be pure Android time:(
|
ndrocchietto_ivano |
but thanks Mark will come back soonish
|
Mark M. |
OK
|
Oct 22 | 9:50 AM |
Mark M. |
if either of you have a question, just ask
|
ndrocchietto_ivano |
tabula rasa
|
Oct 22 | 9:55 AM |
ndrocchietto_ivano |
just a curiosity
|
ndrocchietto_ivano |
the xml files where usually is the layout at compile time become kind of java instructions?
|
Mark M. |
not really
|
Mark M. |
all the XML resources (and the manifest) get "compiled" into a "binary XML" format
|
ndrocchietto_ivano |
gorsh!
|
ndrocchietto_ivano |
that is why you do not need to test!
|
Mark M. |
that format is optimized for speed in reading
|
ndrocchietto_ivano |
I thought there was a kind xml parser under the hood
|
ndrocchietto_ivano |
fascinating!
|
Mark M. |
at runtime, a custom implementation of the XmlPullParser can read in the "binary XML", about 10x faster than the original ordinary XML
|
ndrocchietto_ivano |
i trust you
|
ndrocchietto_ivano |
but so what happens when I give info programatically in Java, for instance if I take an element of the background in the code, let's say an attribute as I want to use an if condition
|
ndrocchietto_ivano |
will still get compiled in binary XML format?
|
Mark M. |
no
|
ndrocchietto_ivano |
double gorsh!
|
Mark M. |
the act of inflating a layout creates a tree of Java objects representing the UI (e.g., LinearLayout, TextView)
|
Oct 22 | 10:00 AM |
Mark M. |
all your runtime manipulations go against those objects
|
Mark M. |
resources are read-only at runtime
|
ndrocchietto_ivano |
I see
|
ndrocchietto_ivano |
with a hierarchy on onMeasure
|
Mark M. |
yes, and all the rest of the ViewGroup work
|
Mark M. |
and that's a wrap for today's chat
|
ndrocchietto_ivano |
that is why when i debug onMeasure with a break point I have a lot of stop on the same row!
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
ndrocchietto_ivano |
thanks
|
Mark M. |
the next chat is Tuesday at 4pm US Eastern
|
ndrocchietto_ivano |
OK
|
Mark M. |
have a pleasant day!
|
ndrocchietto_ivano |
cheers
|
Chandra S. | has left the room |
ndrocchietto_ivano | has left the room |
Mark M. | turned off guest access |