Office Hours — Today, April 14

Tuesday, April 8

Apr 14
3:50 PM
Mark M.
has entered the room
3:55 PM
Mark M.
turned on guest access
IpiRon
has entered the room
4:00 PM
IpiRon
Hello!
Mark M.
hello, IpiRon!
how can I help you today?
IpiRon
View paste (34 more lines)
Hello!

we have an app where we need to implement a private (to our app) PIN entry mechanism similar to the Android OS Pin/Pattern 

screen locking.This private version must function totally separate from whether or not the user has enabled/disabled the Android 

OS version. We have proceeded by creating our own Activity screen for PIN number entry rather than try to use or clone the 

Android object as there are very specific visual items and behavior required. Our simple objectives for now are:

A. If our app is on the screen and the screen 'locks', when the user wakes it up then our PIN entry screen needs to appear.

B. If our app is NOT on the screen and the user runs the app from an icon then our PIN entry screen needs to appear.


...
Mark M.
um, hold on a moment while I read all of that... :-)
"Are you aware of any detailed case studies that could server as a roadmap for implementation?" -- no
"In the OnPowerReceiver what is the correct way to obtain the Application object" -- call getApplication() on the Context that is passed into onReceive()
Andrew O.
has entered the room
Andrew O.
Hi, I've been having trouble saving my scroll position in a listview for rotations. A friend told me that this may be because I'm constantly resetting my ListAdapter, though I haven't found information to back that up. I'm using a CursorAdapter to back my ListView and because SQL queries take some time, I get my cursor using an AsyncTaskLoader and set my adapter for my ListView in onLoadFinished() of the fragment that holds the ListView. Is my friend right? If so, what are some best practices to retain the same adapter across rotations and swap out underlying data?
Mark M.
"3. Is the OnPowerReceiver the proper mechanism for determining the locking/unlocking of the screen or is there a better way to implement, say KeyGuard?" -- I have no idea
IpiRon: I'll swing back to you in a bit to take any follow-on questions, and I apologize for not being more useful on those
4:05 PM
IpiRon
Okay
4:05 PM
Mark M.
"Is my friend right?" -- you should be creating a new adapter on a configuration change, when your activity is destroyed and recreated
"what are some best practices to retain the same adapter across rotations" -- you don't
hold on a moment while I research a better solution
ah, there it is
setSelectionFromTop()
now, AFAIK, that's normally applied automatically
so I don't know quite why you are encountering a problem
but, push come to proverbial shove, hold onto the old position in the Bundle in onSaveInstanceState() (getFirstVisiblePosition()), then re-apply it yourself in after your data is ready
4:10 PM
Mark M.
your data should be coming to you immediately, assuming your AsyncTaskLoader is working properly, as the prior results will be retained across the configuration change
if you are finding that you are re-querying the database after the configuration change, that may be your problem
let me swing back to IpiRon, and I'll be back with you in a bit
IpiRon: your turn -- do you have another question?
IpiRon
I tried: myApp = (IntelliMessageApplication) context.getApplication(); but it says to use .getApplicationContext() so I'll live with that!
Mark M.
what is "it"?
IpiRon
View paste
That will do it for me, I'll probably be back on the next chat session,

Thanks, over and out!
It was hovering over the error in Eclipse!
Mark M.
OK
IpiRon
has left the room
Mark M.
oh, right, getApplication() is only on Activity
and, um, never mind :-)
Andrew: do you have another question?
Andrew O.
It turns out I'm requerying my database on configuration changes. Is there any way to prevent this from happening?
Mark M.
there's a bug in your AsyncTaskLoader somewhere, or in how you are calling initLoader()
does your implementation of AsyncTaskLoader override any methods other than loadInBackground()?
4:15 PM
Andrew O.
Yes, onCanceled(), deliverResult(), onStartLoading(), onStopLoading(), onReset(). I call initLoader in onCreate of my fragment.
Mark M.
hmmm... what are you doing in deliverResult()?
Andrew O.
View paste
@Override
    public void deliverResult(Cursor data) {
        Cursor oldCursor = mCursor;
        mCursor = data;

        if (isStarted()) {
            // Data can be delivered
            super.deliverResult(data);
        }

        if (oldCursor != null && oldCursor != data && !oldCursor.isClosed()) {
            oldCursor.close();
        }
    }
Because I didn't set retainInstance() to true, would my fragment get recreated, causing another call to initLoader?
Mark M.
yes, but that's supposed to be handled by the loader framework
effectively, your Cursor you are returning should be retained automatically
and your next initLoader() call should arrange to deliver that same Cursor back to you
Andrew O.
And onLoadFinished() wouldn't be called again?
Mark M.
that I don't remember
4:20 PM
Mark M.
I gave up on the loader framework a while back
4:20 PM
Mark M.
if you have another question, go right ahead
4:25 PM
Andrew O.
I'm making music player and the now playing screen has a seekbar and a couple of textviews among other things. The textviews indicate the artist/album and the title of the song. The seekbar is constantly updated by a background thread and the textviews are set to autoscroll with the marqueeForever attribute. The TextViews stop scrolling when the music is playing and the seekbar is automatically moving, and resume when the music is paused or the seekbar stops moving. I know the textview autoscroll feature has something to do with View/Widget selection, but I'm not exactly sure how to go about fixing it.
Mark M.
well, the marquee effect is only supposed to take effect when the widget is selected
which means as soon as the user touches just about anything else, the effect will stop
if your objective is for the effect to continue regardless of user input, you're probably going to have to find some other solution
Andrew O.
Oh okay, thanks. One more question: Is it possible to reorder the results in a cursor? I want to display things in alphabetical order but A-Z is before a-z. In short, I'd like to have case insensitive alphabetical order.
Mark M.
ideally, you query the database that way
4:30 PM
Mark M.
I seem to recall that there's a case-insensitive option with ORDER BY
Andrew O.
Okay, thanks! That's all I have for today.
Mark M.
yes, COLLATE NOCASE
e.g., ORDER BY TITLE COLLATE NOCASE
Andrew O.
Thanks :)
Andrew O.
has left the room
5:00 PM
Mark M.
turned off guest access

Tuesday, April 8

 

Office Hours

People in this transcript

  • Andrew O
  • IpiRon
  • Mark Murphy