Office Hours — Today, April 28

Tuesday, April 26

Apr 28
3:50 PM
Mark M.
has entered the room
Mark M.
turned on guest access
3:55 PM
Ron
has entered the room
Ron
(hello)
Mark M.
hello, Ron!
how can I help you today?
Ron
View paste (33 more lines)

We have a simple app that has one and only one Activity: MainActivity. We want the app to have the following behavior:

	1. There should only be one instance of MainActivity, i.e. we cannot have onCreate fired more than once, ever!!!! (We can't have more than one process, period)
	2. The MainActivity can never issue a finish()!
	3. The user can hit the BACK button to minimize the activity in which case they can manually bring up the app by:

		a. Hitting the app icon.
		b. Hitting the app in the recents list.

	4. When the Android device boots up:

		a. The activity must NOT fire onCreate more than once.
		b. The activity must be displayed on top of anything else that is running.

...
Mark M.
um, a lot of what you wrote seems mutually contradictory
it is not possible for the activity to always be over everything and also "minimized"
I guess my main point of confusion is "The activity must be displayed on top of anything else that is running"
that seems to be in conflict with the rest of the description
Ron
That is when the device restarts
Mark M.
OK, why not make your app the home screen, then?
4:00 PM
Ron
Not sure what home screen means?
Mark M.
when you press the HOME button, that is where you go back to
it is Android's equivalent of "the desktop" in a desktop OS, if you will
Ron
Hmmm, we have never seen that. Sounds promising. How do we do it?
Joshua C.
has entered the room
Joshua C.
Hello. :)
Mark M.
(BTW, hello, Joshua -- I will be with you shortly!)
Ron: have your activity implement android.intent.action.HOME instead of (or in addition to) android.intent.action.MAIN, as <action> elements in the <intent-filter> in the manifest
I assume that this app is only going on hardware that you control, that is in some quasi-kiosk sort of setup
Ron
Yes
Mark M.
on Android 5.0+, you might look at actual kiosk mode, with pinned apps
I haven't played with it yet, but that's the general direction Google is heading to support these sorts of scenarios
Ron
Great, we will investigate that.
You can go on to next question and we will ask more later.
Mark M.
OK
Joshua: your turn! do you have a question?
4:05 PM
Joshua C.
Yes, indeed! So... firstly I am designing a software keybaord that I want to implement in android. I'm new to android but have other programming experience, btw. I've looked a bit at the IME documentation (which doesn't seem to be covered in your book), and can't see any sign of what I want to do and I'm not sure such is even possible...
Mark M.
writing an IME is a fairly niche topic, which is why I have not gotten to it yet
Joshua C.
I want my custom keyboard to not shrink the content activity that it's interacting with, but instead leave it full screen (scroll it in some cases) and use the entire screen to have a translucent keyboard.
Mark M.
yeah, I have no clue if that's possible or not
Joshua C.
Hmm...
Mark M.
you could try asking on a place like Stack Overflow, but that's a really specialized subject, and so I do not like your odds of getting an answer
Joshua C.
Well, any thoughts on what directions, code-wise I could look? Can you do low-level screen writing from an IME at all?
Mark M.
well, AFAIK, the IME itself is a separate window from the activity window
and while standard IMEs use that window for rows of key-like buttons, that's not a requirement
for example, Graffiti2 is available as an app
Joshua C.
Well, in what context that you do know about can one draw low-level over other running apps? Any?
4:10 PM
Joshua C.
Yes... and the IME window could be very small... but could I get access to the Canvas of the current activity?
Mark M.
oh, definitely not
that's in a separate process, let alone a separate window
but you don't need that anyway
the issue isn't drawing
my Graffiti2 reference was in reference to that
Joshua C.
Okay, I'll check out that app....
Mark M.
Graffiti/Graffiti2 was the old input mechanism used on Palm devices, back in the 1990's/2000's
Joshua C.
I remember it.
Mark M.
so that IME did not have keys
instead, it had drawing areas
and showed what your finger/stylus was drawing
if they can do that, rendering what you want should not be a problem
the two problems that I see are: translucency and full-screen
I don't know if you supply the window background on the IME window or if that is system-supplied
Joshua C.
Okay...
Mark M.
and I do not know what degree of control you have over the window size
that's mostly because I haven't written an IME, and therefore I don't know the details
let me take another question from Ron while you chew on this, and I'll be back with you shortly
Ron: your turn! do you have another question?
Ron
It is our understanding that launchMode = 'singleInstance' means that the onCreate will fire only once. Is that correct to your knowledge?
Joshua C.
Great. :)
Mark M.
I'd phrase it more as "the existing activity instance, if it exists, will be reused"
4:15 PM
Ron
If it doesn't exist then it will be created then, correct?
Mark M.
yes
if you somehow ensure that the activity lives for the duration of the process, then there should be only one onCreate() for the duration of that process
Ron
How do we determine if there are any ANdroid known issues on these types of things?
Mark M.
::shrug::
you are welcome to peruse b.android.com and see what's out there
Ron
Okay, you can go to next question and we are going to think a bit on this.
Mark M.
OK
Joshua: back to you! do you have another question?
Joshua C.
Well...
I'm interested in writing another app I'm not sure is possible...
Can one write a replacement volume control app? It would need to be able to change the volume on the fly, affecting the various streams that are playing from apps.
Mark M.
I haven't played in this area in a while, but you used to be able to
I have (had?) a Volumizer sample app in the book
Joshua C.
(It's going to take me a while to really properly investigate this keyboard issue, but I'll work on it. I was hoping you had more leads.) ;)
Okay, I missed that, will go and take a good look at it.
4:20 PM
Mark M.
now, the audio APIs changed somewhat over the years, so I am not 100% convinced that you can still change the audio globally
it's not an area I have paid a ton of attention to
but, IIRC, the relevant methods were on the AudioManager system service
Joshua C.
Okay, great. Thanks.
Mark M.
let me switch over to Ron, and I'll check back with you shortly
Ron
View paste
The same app is reading/writing to a SQLite database. We instantiate a single SQLiteDatabaseHelper object. The app also is a content provider to another of our apps which performs SELECTs and UPDATEs using the Content Provider which is using the same SQLiteDatabaseHelper object. We are wondering if we need further synchronization external to the existing database commands, i.e. JAVA synchronization. We are seeing occasion dumps like: 04-28 14:46:10.108 E/SQLiteConnection( 2669): startPos 3177 > actual rows 3010
04-28 14:46:10.108 E/CursorWindow( 2669): Failed to read row 1588, column 9 from a CursorWindow which has 0 rows, 24 columns.
04-28 14:46:10.108 W/System.err( 2669): java.lang.IllegalStateException: Couldn't read row 1588, col 9 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
04-28 14:46:10.118 W/System.err( 2669): 	at android.database.CursorWindow.nativeGetDouble(Native Method)
04-28 14:46:10.118 W/System.err( 2669): 	at android.database.CursorWindow.getDouble(CursorWindow.java:556)
04-28 14:46:10.118 W/System.err( 2669): 	at android.database.AbstractWindowedCursor.getDouble(AbstractWindowedCursor.java:87)
04-28 14:46:10.118 
...
Mark M.
Ron: back to you! do you have another question?
if the results of your query will be over ~1MB, you get a window of data
4:25 PM
Mark M.
as you navigate the Cursor, the database is queried again to populate the next window
if the database changes enough while that is going on, you might get the sort of errors represented by that stack trace
however, a 1MB query result is kinda big
so I'd focus on trying to have more focused queries
Ron
Okay, we agree that 1M is pretty large and we don't think our retrivals will be that big.
Mark M.
in that case, you should not run into this
Ron
Okay, go to Joshua and we will think more.
Mark M.
OK
Joshua: do you have another question?
Joshua C.
Not so much yet. I'm just getting into android and of course all the things I want to write are a bit out of the box and will take more research. :)
And fiddling of course.
Mark M.
the IME is definitely "diving into the deep end of the pool"
OK, unless somebody else joins in, it's free-for-all time: if you have a question, just chime in
Joshua C.
Yeah, I have a bad habit of that. I've been working on a layout for a while... a one-handed keyboard layout.
Ron
We have enough to research now so we will exit. If we have more today we will rejoin. THANKS!
Ron
has left the room
Joshua C.
And I really want to implement it. Once I get it implemented (even if not properly in an IME), I also want to figure out a way to use it as a bluetooth keyboard to other devices.
4:30 PM
Mark M.
well, if you want to do something to control other devices, you would not use an IME in all likelihood, but rather just a regular activity
if you want to support both modes, that's fine, but you'll want to try to insulate your code from exactly what it's drawing into
to minimize code duplication, etc.
Joshua C.
Yes... but I want to accomplish both... implementations of the same layout. Getting it to work as an IME is critical, and probably the hard part.
Yes, good point.
Mark M.
agreed
Joshua C.
I'm starting to implement it now just in a simple activity.
Mark M.
though speaking the HID Bluetooth protocol might not be easy
Joshua C.
Indeed, that will be hard. Hopefully I don't have to completely write the implementation from scratch, but I haven't looked into it yet.
Anyway, thanks for leads. I'll see where I can get and if I hit a wall, I'll try again, or maybe on stackoverlow. :)
Mark M.
you are very welcome
Joshua C.
has left the room
4:35 PM
Raghav C.
has entered the room
Raghav C.
Hello
Mark M.
hello, Raghav!
how can I help you today?
Raghav C.
Hey Mark , firstly thank you for your wonderful book. It is very detailed and has been helpful for me.
Mark M.
thanks for the kind words!
Raghav C.
I am currently working on a project for visually impaired people. I want to support custom gestures . I am not able to find relevant info or samples for the same.
Do you have any sample accessibility project or docs related to supporting gestures?
Mark M.
I am not clear what you mean by "custom gestures"
and what that has to do with accessibility
4:40 PM
Mark M.
can you give me an example?
Raghav C.
yeah suppose I have a really long list and in order for the user to easily navigate the list, I was thinking of adding some custom gesture which when the user performs the gesture, will scroll through 20 or 30 items directly
Also, a custom gesture anywhere within the app to bring up the home activity of my application.
Mark M.
the accessibility APIs are for device-wide effects
and you cannot do device-wide gestures especially well
you are certainly welcome to have activities in your app pay attention to gestures
Raghav C.
For accessibility, we have talkback gestures where the user is able to navigate through the application using gestures
Mark M.
AFAIK, Talkback-style cannot be implemented via Android SDK apps
Raghav C.
Ok how can I do that? Is there a way to say listen for a circular gesture and then invoke an action?
Mark M.
beats me
over a list, I presume it's possible, but I can come up with a *long* list of things that I would rather do
coordinating touch events between lots of different moving parts (list rows, the list itself, your activity) is not fun
I settle for what GestureDetector does for me, and that's about it
Raghav C.
ok so what do you suggest instead?
4:45 PM
Mark M.
I do not really have much in the way of suggestions here
I apologize for not being more useful in this particular area
Raghav C.
Ok fine thanks. I was thinking that it will be easier for visually impaired people to use gestures to navigate around the application as well.
Ok fine. Not a problem. I will keep looking
Mark M.
if you have other questions, go right ahead
Raghav C.
I dont have any other questions. Accessibility is the only topic I had in mind.
Thanks
4:55 PM
Raghav C.
has left the room
5:00 PM
Mark M.
turned off guest access

Tuesday, April 26

 

Office Hours

People in this transcript

  • Joshua Chambers
  • Mark Murphy
  • Raghav Chandra
  • Ron