Office Hours — Today, September 13

Monday, September 9

Sep 13
9:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
Gaurav B.
has entered the room
Mark M.
hello, Guarav!
how can I help you today?
10:00 AM
Luca
has entered the room
Luca
Hi all
Mark M.
hello, Luca!
Luca: I think Guarav is just lurking -- do you have a question?
Luca
Yes
I'm using some global singleton classes that are eager initialized with the app context inside onCreate of the Application class, i have read on some stackoverflow questions that sometimes static variables can become null on low memory and when you resume the app onCreate is not recalled. Can that happen to my singleton classes too?
Mark M.
"sometimes static variables can become null on low memory" -- your process can be terminated at any point when you are not in the foreground
"when you resume the app onCreate is not recalled" -- if your process was terminated, onCreate() will be called on relevant components (e.g., the activity that the user is launching)
Luca
i need the onCreate of the Application class
Mark M.
that too will be called when your process is starting up
10:05 AM
Luca
ok i have other questions
On some Android code i have noticed singleton classes that uses a retained fragment to preserve the instance instead of a static variable. What is the difference?
Mark M.
(Guarav: if you have a question, let me know)
Gaurav B.
hi mark
Mark M.
singletons should have nothing to do with fragments
by which, I mean that a fragment should not be a singleton, nor should a singleton reference a fragment
a fragment can reference a singleton
the objective is to avoid singletons where possible -- that's standard Java advice, to reduce the odds of memory leaks
Gaurav B.
i wanted to ask you that.. through fragments .. is it easier.. for me to make a dasbhoard.. kind of view..
like that of linked in
or Google plus
Mark M.
Guarav: I have no idea, as I do not use LinkedIn nor Google+
Gaurav B.
I am just asking that for a dashboard kind of page
Mark M.
Guarav: I would not expect fragments to necessarily be involved in "a dashboard kind of page"
I certainly would not expect fragments to somehow make it easier
Gaurav B.
the main thing is that i have seven fragments..
Mark M.
but, again, there are many definitions off "a dashboard kind of page", and therefore I may be thinking of something other than what you are thinking of
Gaurav B.
which i need to go to .. as per the requirement
but i needed a central navigator..
For example there is a chat fragment.. Details fragment etc
and.. i needed to have a page.. or activity from where i can go to each fragment and come back
i hope it makes sense
10:10 AM
Gaurav B.
and I apologize for not able to answer you before mark..
Jeff
has entered the room
Jeff
hello
Mark M.
Guarav: I have no means of answering your question, sorry
Gaurav B.
no problem thanks
Mark M.
(Jeff: Hi! be with you shortly!)
Gaurav B.
i think i am not able to communicate properly
Jeff
no rush - take your time
Mark M.
Luca: to wrap up from your previous question, to retain data through a configuration change, use onSaveInstanceState() or a retained fragment, not a singleton
Jeff: OK, your turn -- do you have a question?
Jeff
hi Mark
I was about to put my app in the store and tested on the new Droid Mini running 4.2.2. Of course, a problem occurred which I'm struggling with.
setting the camera parameter rotation to 90 degrees results in a Camera error 100 in takePicture()
setting the rotation parameter to 0 eliminates the error but the captured image is rotated 90 counter-clockwise
Mark M.
are you using the Camera class directly yourself, or are you seeing this using my CWAC-Camera library?
Jeff
camera class directly
10:15 AM
Mark M.
in general, working with the camera is full of device-specific quirks
which is why I am working on CWAC-Camera, to try to hide those problems
you might try to run my demo app on the Droid Mini and see if it works or similarly crashes
Jeff
what I really worry about is solving this device's problem but the next one hits
that's a good idea - I'll try your demo app
Mark M.
I feel your pain :-)
Gaurav B.
has left the room
Jeff
I could give up setting parameters but I think most users will use portrait mode
Mark M.
if the demo app works in all orientations, then I must be doing something right to address this issue, and perhaps you can switch to use my library, or figure out what I'm doing differently than you
Jeff
and so I'll be capturing images that are wrong
Mark M.
if the demo app crashes, then it's on me to get my hands on the Mini and fix it
note that not every device will actually honor the orientation properly -- I have to manually rotate the image for some devices in my library code
Jeff
I'll try your demo app
Luca
(tell me when i can speak)
Mark M.
Luca: your turn now -- go ahead
Jeff
yes - I change the orientation. this is the first time that parameters caused error 100
go ahead Luca
thanks Mark
Luca
I know that i have to use retained fragment to preserve data or asynctask for callbacks. But for something like a SQLiteOpenHelper i think that a singleton linked to an application is better, i'm right?
Mark M.
correct
Luca
ok
In my application i'm using both sqlcipher and openssl (the latter to encrypt big files). I have some small files (10-20k) that i need to encrypt too, is better to use a blob column in sqlcipher or encrypted files?
Mark M.
for security reasons, you really don't want to hold onto the user's passphrase in memory any longer than necessary
10:20 AM
Mark M.
using encrypted files would require you to hold onto their passphrase, for encrypt/decrypt operations
hence, from a security standpoint, it will be better to store those in SQLCipher
that's not necessarily the most convenient solution
IOCipher would be a "middle ground" alternative
it gives you an API that looks like standard Java file I/O, but the contents are stored in SQLCipher
I hope to be covering IOCipher in the next book update, or else the one after that
Luca
i have already looket at iocipher but there are some issues like that the file must be less of the amount of ram
*looked
Mark M.
you will have the same problem with BLOB columns
if you need to have files bigger than that, storing them separately, encrypted, will be your only option that I can think of
Jeff: do you have another question?
10:25 AM
Mark M.
Luca: do you have another question?
Luca
i'm already using openssl to encrypt big files with success and i'm using sqlcipher to store references and some other data, i wanted to understand if for small files related to a table row is better to use a blob
Mark M.
given your need to keep the passphrase around, I cannot say whether one approach is better than the other for small files
if either of you have additional questions, chime in
10:30 AM
Luca
ok, regarding the passphrase thing i didn't understand.. to query the sqlcipher database i need the password anyway to call "getReadableDatabase" and "getWritableDatabase"
Mark M.
correct, but ideally you do that quickly after obtaining the passphrase from the user
whereas normally with SQLite, you might just hold onto the SQLiteOpenHelper instance and get the database from it when needed, with SQLCipher, you want to hold onto the SQLiteDatabase object, so you only need to use the passphrase once
10:35 AM
Luca
sqlcipher will not hold the password in memory to encrypt/decrypt pages?
Mark M.
it will not hold the original passphrase entered by the user
it will have the hashed passphrase
at least, that is my understanding based on some discussions with the SQLCipher authors
Luca
ok now i have understand what you mean, but i think that is not my case because my "password" is the key that i use to encrypt normal files with openssl. This key is initially decrypted through the passphrase entered by the user
10:40 AM
Jeff
has left the room
10:45 AM
Mark M.
if you have another question, go right ahead
Luca
I'm using the MediaStore to get thumbnails of images stored on the device and i know that thumbnails are cached on external storage, i took a look at the Gallery app code and i have noticed that it generates thumbnail in memory from the original image without using MediaStore. Why that? Maybe because thumbnail sizes of MediaStore are not good for views dimension in Gallery?
Mark M.
"Why that?" -- you would have to ask Google
I have never examined the Gallery source in any detail
and hence I have no idea why they would have made any particular implementation decision
Luca
ok the last question, what is the difference between external and internal uri of MediaStore?
Mark M.
do you mean INTERNAL_CONTENT_URI and EXTERNAL_CONTENT_URI?
Luca
yes
Mark M.
I am not certain
the description of INTERNAL_CONTENT_URI does not make much sense to me
10:50 AM
Mark M.
I have only ever used EXTERNAL_CONTENT_URI
I have not run experiments to see what I would get back if I used INTERNAL_CONTENT_URI, sorry
Luca
for example if i start a gallery intent to pick a media item, the returned content uri will be always something on EXTERNAL_CONTENT_URI?
Mark M.
I would assume so, but I have not done that specific bit of analysis, sorry
Luca
ok
thank you for all your answers
bye!
Jose L.
has entered the room
Mark M.
hello, Jose!
Jose, the chat is close to ending: do you have a quick question?
10:55 AM
Jose L.
I am afraid I completely forgot about this session
Mark M.
well, that may have been my fault
it was originally scheduled for yesterday
I had to move it due to a conflict
Jose L.
I wanted to ask you about some architecture-design topics
but I am afraid it's too little time
Mark M.
probably
Jose L.
hopefully next week
and already looking forward to attend to your talk at the apps world europe
in london
Mark M.
I apologize for having had to move the session
cool!
Jose L.
im also a "speaker" there ^^
well... taking part in an open table discussion, not a speaker per se but
Mark M.
ah, the design one, right?
Jose L.
yeah
Mark M.
alas, I will not be able to attend that one, as I have an evening "In the Brain" session with Skills Matter that evening
11:00 AM
Jose L.
well I would be surprised if we could tell anything you don't know already
Mark M.
well, I am certainly not a design expert
Jose L.
me neither, I'm trying to get better at it
Mark M.
:-)
well, with luck, you'll get a chance to hop in an upcoming chat, and we can cover your architecture questions
the next ones are Tuesday at 7:30pm and Thursday at 10am (both times Eastern)
but that's a wrap for today's chat
have a pleasant day!
Luca
has left the room
Jose L.
has left the room
Mark M.
turned off guest access

Monday, September 9

 

Office Hours

People in this transcript

  • Gaurav Bhatnagar
  • Jeff
  • Jose Luis
  • Luca
  • Mark Murphy