Feb 23 | 8:50 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Feb 23 | 8:55 AM |
EGHDK | has entered the room |
Mark M. |
hello, EGHDK
|
Mark M. |
how can I help you today?
|
Tom | has entered the room |
Mark M. |
hello, Tom!
|
Tom |
Hi Mark!
|
Tom |
good morning
|
Mark M. |
Tom: EGHDK got in first, so I'll take a question from him first, then I'll circle back to you
|
Tom |
Ok
|
EGHDK |
Hey Mark, quickish question I guess. I tried using your camera library. Works great for what I need, but I noticed a weird issue. Seems like on Samsung devices when I take a picture while on a phone call (with my headset) the camera shutter and my phone call, came through on the actual phone speaker, the shutter ended, and the call went back to my headset. Ideas?
|
Mark M. |
beats me
|
Mark M. |
I am not doing anything myself in the library with respect to audio
|
Mark M. |
other than asking the camera to play the shutter sound
|
Mark M. |
and AFAIK that doesn't include any information about where and how to play the shutter sound, or even what the shutter sound *is*
|
Mark M. |
IIRC, I have hooks in there for you to handle shutter sounds yourself, in which case you can always try doing something independently
|
EGHDK |
Gotcha. I tried on other devices, and no issue. Seems to be a samsung issue. That's possible... right?
|
Mark M. | |
Mark M. |
oh, sure
|
Feb 23 | 9:00 AM |
Mark M. |
the camera behavior is very device-specific
|
Mark M. |
:: insert string of profanities here ::
|
EGHDK |
Okay, so last question regarding this... then I'm out. How would I change the sound. I have my own camerahost extending simplecamerahost.
|
Mark M. |
see the link that I pasted into the chat a moment ago
|
EGHDK |
But do I simply ovverride getShutterCallback()?
|
Mark M. |
yes
|
Mark M. |
and return your own Camera.ShutterCallback
|
Mark M. |
and in there, do whatever you want
|
EGHDK |
what is my own though? Camera.ShutterCallback is abstract...?
|
Mark M. |
it's either an interface or an abstract class
|
EGHDK |
Sorry I was just confused when I tried return new Camera.ShutterCallback
|
Mark M. |
it's an interface
|
Mark M. |
create your own class implementing the interface
|
EGHDK |
Okay, so is there any class that implements it already, that might be a member of SimpleCameraHost that I can just return?
|
Mark M. |
and in there, you will have an onShutter() method that is called, where you can do something (e.g., play back a Michael Bay 'splosion sound)
|
EGHDK |
Okay, so I'll create my own class. Gotcha! Thanks.
|
Mark M. |
Tom: your turn! do you have a question?
|
EGHDK |
I've never worked with a method that returned an interface before (at least knowinlgy) thanks. That makes sense. See ya later mark.
|
Tom |
I do! It's concerning a small app I made to help get my head around the SQLite database chapter in the Omnibus
|
Feb 23 | 9:05 AM |
Tom |
What it does is read the rows from the Browser history and Browser.BOOKMARKS_URI, and that works fine, but I have an issue when I try to write to it
|
Mark M. |
um, that would be using a ContentProvider, not SQLite directly
|
Mark M. |
which is fine, of course
|
Tom |
I store a bunch of presets in a DatabaseHelper, and then copy them to the browser history
|
Venkat | has entered the room |
Mark M. |
ah, ok
|
Mark M. |
(BTW, hello, Venkat -- I will be with you shortly!)
|
Venkat |
Hi Mark :-)
|
Tom |
The problem is that, even though it shows in my app that everything has copied correctly..when I load up the browser, the history is untouched. Strangely though, the entries I've copied DO show up in the search bar if I being to type them in. I wondered whther you had some ideas on why this might be?
|
Johnny | has entered the room |
Mark M. |
(BTW, hello, Johnny -- I will be with you after Venkat!)
|
Mark M. |
Tom: it's possible that the browser is caching the bookmarks
|
Johnny |
Hi Mark, thank you
|
Mark M. |
try swiping the browser off of the recent tasks list, then restart it
|
Tom |
I gave that a try - the ones I wrote in there never appear. Another thing though is that if I write them as bookmarks, rather than history entries, then they do appear as bookmarks in the browser.
|
Mark M. |
:: shrug ::
|
Mark M. |
that behavior is up to whoever wrote that browser
|
Feb 23 | 9:10 AM |
Mark M. |
if this is the classic AOSP Browser app, you're welcome to poke through its source code and see what it does
|
Mark M. |
let me take questions from the others, and I will be back with you in a bit
|
Mark M. |
Venkat: your turn! do you have a question?
|
Tom |
Ok
|
Venkat |
View paste
|
Venkat |
and I get a compile error - ndk-build not found
|
Venkat |
If I change it to:
|
Venkat |
View paste
|
Venkat |
it comiples correctly
|
Mark M. |
that makes sense
|
Mark M. |
ndk.dir is not going to be used by Gradle's commandLine directive
|
Mark M. |
Gradle has no idea about a local.properties file, let alone an ndk.dir property in there
|
Venkat |
ok, then that explains things
|
Mark M. |
that is for ndk-build itself, and for the nascent ndk closure in the Gradle for Android plugin
|
Venkat |
Thats all from me today.
|
Mark M. |
if you put /path/to/ndk in your $PATH, you could avoid the duplication
|
Mark M. |
or, you could read in local.properties yourself in the Gradle script, grab ndk.dir, and use it to build up the first parameter to commandLine
|
Venkat |
in one of the gradle files?
|
Mark M. |
well, by $PATH, I meant the PATH environment variable in your development OS
|
Venkat |
ok
|
Venkat |
Will also research a bit about grabbing from local.properties
|
Mark M. |
in my book, I have an example of reading a custom properties file and using that to automatically set the versionCode
|
Feb 23 | 9:15 AM |
Mark M. |
reading in local.properties would work much the same, except that you would not be modifying the file
|
Mark M. |
Johnny: your turn! do you have a question?
|
Johnny |
Yep, I was wondering what's the best way to check if an alarm/timer should go off without wasting a lot of CPU cycles
|
Mark M. |
what do you mean by "check if an alarm/timer should go off"?
|
Johnny |
So I compare the current time in milliseconds to a stored one
|
Johnny |
and I want to check if the current time is greater than the stored one
|
Mark M. |
is the alarm/timer only relevant while your app is in the foreground? or should it go off even if your app is in the background (or gone)?
|
Johnny |
Actually, I was wondering what's the difference since in one area of my app I would need it constantly running in the background, and another when the user is in the activity and there's a textview that counts down the timer
|
Johnny |
So both
|
Mark M. |
why do you think that you "need it constantly running in the background"?
|
Feb 23 | 9:20 AM |
EGHDK | has left the room |
Mark M. |
in the background, doesn't it only matter if you get control at the proper time?
|
Johnny |
Oh it's a reminder app, so I'm assuming I'm going to have to wake the CPU pretty often, unless there's a way to set specific times..
|
Johnny |
yeah you're right
|
Mark M. |
for the background stuff, use AlarmManager
|
Mark M. |
teach it the nearest event
|
Mark M. |
when it gives you control, issue the reminder, plus tell AlarmManager to give you control for the next event
|
Mark M. |
there is a chapter on AlarmManager in the book to show the basics
|
Mark M. |
while you have an activity in the foreground that wants to show some sort of time-remaining counter, use a postDelayed() "loop"
|
Mark M. |
call postDelayed() on a Runnable
|
Mark M. |
that Runnable updates the counter, then schedules itself to run again via postDelayed()
|
Johnny |
Ah right. Just to also confirm, I shouldn't use JobScheduler pre-lollipop right
|
Mark M. |
correct, if for no other reason than it is inexact, and reminders usually need to be exact
|
Mark M. |
I have an example of a postDelayed() loop in the book as well
|
Feb 23 | 9:25 AM |
Johnny |
For postDelayed() do I set the delay amount?
|
Feb 23 | 9:25 AM |
Johnny |
ah ok I'll check that out
|
Mark M. |
yes, that's the second parameter to postDelayed()
|
Mark M. |
so, postDelayed(yourRunnable, 1000) runs the Runnable around 1000 milliseconds from now
|
Mark M. |
it's not millisecond-level precise, though -- you use it for approximate timing and giving you control on the main application thread to update your UI
|
Mark M. |
the actual UI update would be based off of a better calculation (e.g., how much time is remaining on the countdown?)
|
Mark M. |
let me take questions from the others, and I will be back with you in a bit
|
Mark M. |
Tom: your turn! do you have another question?
|
Tom |
Hey Mark, no, just more of the same
|
Johnny |
Thank you Mark, that's all from me
|
Johnny | has left the room |
Mark M. |
Tom: "just more of the same"?
|
Tom |
I'm trying to figure out where to put my attention next to figure out why the browser history isn't updating in the default Browser
|
Mark M. |
well, again, that depends upon what "the default Browser" is
|
Mark M. |
there is the AOSP Browser, there is Chrome, there is Samsung's "Internet" browser, etc.
|
Tom |
Yea - I'm testing on a Nexus 7 with Chrome
|
Mark M. |
well, Chrome is closed source
|
Mark M. |
and there is no requirement that Chrome use that ContentProvider for anything, let alone everything
|
Tom |
I see
|
Feb 23 | 9:30 AM |
Tom |
Quick question in that case in the Browser class there is a method called "updateVisitedHistory()", which produces same results to my app
|
Tom |
do you happen to know whether this is more targeted towards people who are developing their own app? As it's unlikely to work with any Android browser based on my tests
|
Tom |
own browser**
|
Mark M. |
I cannot say what Google had in mind
|
Mark M. |
I can say that system-supplied ContentProviders are an *available* facility, but usually not a *mandatory* facility
|
Tom |
I understand
|
Mark M. |
or, to put it another way, if I were writing a Web browser, there's no way in $DEITY's green Earth that I would be using this provider
|
Tom |
Ha! That doesn't sound encouraging
|
Mark M. |
as I don't think that anything exposed by this provider ought to be exposed to arbitrary third party apps
|
Mark M. |
and some browser makers probably have the same attitude
|
Tom |
I'm surprised in a way though, because there are quite a few popular "history cleaner" apps available in the play store, that profess to be able to wipe a browser's history - I would have assumed that if the history can be wiped, it can also be added to
|
Mark M. |
that presumes that the "history cleaner" apps do what they claim to
|
Mark M. |
there's no question that they can wipe out what is in this provider
|
Feb 23 | 9:35 AM |
Mark M. |
that will not affect all browsers for all data, though, as some browsers will have their history data stored elsewhere
|
Mark M. |
to put it another way, if I wrote a browser app, and a "history cleaner" app could clean my app's browser history, that's a security flaw in my app that I need to fix
|
Mark M. |
unless I specifically put the history into this provider
|
Mark M. |
and in that case, I should be slapped with a trout
|
Tom |
Haha
|
Mark M. |
fortunately, I have not written a browser, and so no actual trout were harmed
|
Mark M. |
let me take a question from Venkat, and I can come back to you in a bit
|
Tom |
Glad to hear it - well, that certainly makes sense, although it's a bit disappointing
|
Mark M. |
Venkat: your turn! do you have another question?
|
Tom |
Of course
|
Venkat |
Do I have to create a task for NDK build? I have an Android.mk in the jni folder and I was expecting the build system to pick that up automatically and run ndk-build
|
Venkat |
but it does not
|
Mark M. |
Gradle for Android definitely does not integrate with ndk-build
|
Mark M. |
Gradle for Android has an ndk closure that replaces ndk-build
|
Mark M. |
but it also replaces the makefiles
|
Mark M. |
and is not especially sophisticated
|
Mark M. |
and therefore is slated for significant change
|
Venkat |
I have the ndk closure in my build.gradle
|
Venkat |
so can I still need to create a task?
|
Mark M. |
no, you do not need a task then
|
Mark M. |
however, Gradle for Android will not be using ndk-build
|
Mark M. |
it will do its own NDK build process
|
Feb 23 | 9:40 AM |
Venkat |
hmm ... and it is not compatible with Android.mk?
|
Mark M. |
it ignores Android.mk
|
Venkat |
ok, got it
|
Mark M. |
at least, AFAIK
|
Venkat |
that is what I am seeing
|
Mark M. |
it's all kinda hazy, and it's on the tools team's plate to make it better
|
Venkat |
I found the chapter you were referring for custom properties file, will look into it
|
Venkat |
thanks, Mark
|
Mark M. |
you are very welcome
|
Mark M. |
Tom: back to you -- do you have another question?
|
Venkat | has left the room |
Tom |
No, thank you Mark
|
Feb 23 | 9:50 AM |
Guy W. | has entered the room |
Guy W. |
Hello
|
Mark M. |
hello, Guy!
|
Mark M. |
Guy: Tom is out of questions, so it's your turn -- do you have a question?
|
Guy W. |
OK
|
Guy W. |
I making a screenshot of a webview and saving it
|
Guy W. |
I'll post the code
|
Feb 23 | 9:55 AM |
Guy W. | |
Guy W. |
I want to add an overlay to the image
|
Guy W. |
where should i code it before the asynctask or in the doInBackground method?
|
Mark M. |
Guy: the chat is nearly over -- can you please ask your question?
|
Mark M. |
you could do it in either place
|
Guy W. |
thanks
|
Mark M. |
there's nothing directly affecting the UI, and so doing it in doInBackground() should be safe
|
Mark M. |
and it saves doing that work on the main application thread
|
Guy W. |
graet. :)
|
Guy W. |
thank you
|
Guy W. |
have a ncie day
|
Guy W. |
nice
|
Feb 23 | 10:00 AM |
Mark M. |
that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to http://commonsware.com/office-hours/ shortly
|
Guy W. |
cool
|
Mark M. |
the next chat is tomorrow at 4pm US Eastern
|
Mark M. |
have a pleasant day!
|
Guy W. |
:-)
|
Tom | has left the room |
Guy W. | has left the room |
Mark M. | turned off guest access |