Office Hours — Today, September 29

Tuesday, September 27

Sep 29
7:20 PM
Mark M.
has entered the room
Mark M.
turned on guest access
7:35 PM
Bill B.
has entered the room
Bill B.
HI Mark
Mark M.
howdy, Bill!
how can I help you today?
Bill B.
I have a question about Instumented Testing and TouchUtils.drag methods
Mark M.
oy
I'll give it a shot, but I haven't used drag()
7:40 PM
Mark M.
what specifically is your question?
Bill B.
when I run TouchUtils.dragViewBy(this, knightImage,Gravity.BOTTOM,50,50); I get a RuntimeException stating that INJECT_EVENTS is not set
but I only have one ActivityRunning and I'm not trying to access any other window or application that I am aware of
Mark M.
INJECT_EVENTS is a permission
in your line of code, what is "this"?
oh, never mind
knightImage is an ImageView?
Bill B.
the instance of ActivityInstrumentationTestCase2
yes
let me show you part of the stack trace
Mark M.
I certainly wouldn't expect that error
7:45 PM
Mark M.
is it a case where other places dragViewBy() is working and it's not here?
or does it fail for you everywhere?
Bill B.
this is the only place i'm using it
do you want to see the whole test method?
Mark M.
is the activity actually on the screen when you are running the test?
Bill B.
View paste
here is the exception java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
Mark M.
I'm seeing a bunch of posts suggesting that this error crops up if the lock screen is active when the test is run
Rich F.
has entered the room
Mark M.
howdy, Rich!
Bill B.
but the screen is definately not locked
Rich F.
Rawr! Hello all :) woot! I have been trying to make this for WEEKS! I finally made it!
Bill B.
I have other tests that I can see running
Mark M.
hmmmm
I don't know what to tell you
like I said, I've never used dragViewBy() or kin
Bill B.
ok, I'll look at the links you pointed me to
Mark M.
sorry
Rich: do you have a question?
Bill B.
thanks for the help
7:50 PM
Rich F.
I was posting an answer on SO for someone last night and they had a good question, I just wonder if I was completely correct... He starts an Activity from Activity1 and wanted to use getIntent() in Activity2
Does the Intent hold any information from the initial class? I looked and didn't see anywhere this information was
located in the Intent
Mark M.
if Activity1 calls startActivity() for Activity2, and you call getIntent() on Activity2, you will see nothing related to the Intent used to start Activity1
that's a good thing, because startActivity() might start up another app entirely, and you don't want apps somehow being able to walk some Intent chain and get at all sorts of non-public data
Rich F.
Ok that is what I told them.
huh?
OH nvm ok I see I think...
Mark M.
Bill: do you have another question?
7:55 PM
Mark M.
OK, does anyone have another question?
Rich F.
I am really unprepared today! I just happen to be here at my comp and saw the time. Sorry I have not prepared better. I do have a couple quick questions though if you don't mind
Mark M.
fire away
Rich F.
In my app I have an issue I had to tackle recently. I added an appwidget and start a service with it (indirectly atm)
the service needs to tell the appwidget that it is active. I tried using sharedprefs to do this however there naturally a race condition
Mark M.
a service cannot "tell the appwidget" about anything
Rich F.
right
Mark M.
a service can *update* the RemoteViews that renders an app widget, though
what is your objective of the "needs to tell" part?
8:00 PM
Mark M.
for example, if your AppWidgetProvider simply needs to know if the service is started when it does its next regularly-scheduled update, just use a static data member
Rich F.
To change the "state" of the appwidget saying the service is "On" right now the service sets a flag in a intermediate class that I use as a sort of "go between" between the appwidget, service, and activity(there is a textview that is updated as well)
So it needs to be pretty immediate, this 'state' change... I found that broadcasting a message was unreliable
in the timing
Mark M.
what do you mean by "the 'state' of the appwidget"?
Bill B.
has left the room
Mark M.
do you mean "the pixels that the user sees with his/her eyeballs"? or something else?
Rich F.
Yeah the On or Off state
the visual
Mark M.
ok, have the service use AppWidgetManager to update the app widget
(directly or via your intermediate class, whatever)
and use a boolean isRunning static data member for future AppWidgetProvider onUpdate() calls
(assuming there are any)
updating the activity could be by broadcast, or createPendingResult(), or Messenger, etc.
8:05 PM
Rich F.
YOU RULE!!!! I only use AppWidgetProvider never knew that AppWidgetManager (according to the docs) "Updates AppWidget state; gets information about installed AppWidget providers and other AppWidget related state."
Mark M.
you get passed in an AppWidgetManager in onUpdate() of your AppWidgetProvider
it's how you are getting your RemoteViews to the home screen
however, you can get an AppWidgetManager whenever you want, if you want to "push" an update to the home screen outside of any standard polling period
Rich F.
Yeah see I don't even touch that! I am looking at my code and I think this is going to be useful
Man you just gave me hours of research... lol
Mark M.
this stuff is covered in the Advanced Android book, FWIW
Rich F.
Oddly enough until about a month ago I used your books for very specific reasons... then I started actually reading them all the way through and... WOW it really opened me up to some great ways of approaching my Android development
8:10 PM
Mark M.
glad you like 'em!
Rich F.
no, love them!
I never went to school for any of this so I have MANY books and 9 languages later... Android! Anyway thank you Mr. Murphy you have def given me much to think about. You have a wonderful weekend sir
Mark M.
you too!
Rich F.
Oh and to finish my earlier thought... your books are by far in the top ten of ALL i have
NetApex
has entered the room
Rich F.
Thank you
NetApex
Evening
Mark M.
Rich: you are very welcome
howdy, NetApex!
Rich F.
has left the room
NetApex
How are you?
Mark M.
do you have a question?
NetApex
Quick question
Embedding YouTube
Since it ends up in webview, is there a way to account for screen size differences?
Mark M.
let's back up a step
NetApex
Lol okay
Mark M.
you're explicitly forcing an embed, rather than launching the YouTube player -- correct?
NetApex
Correct
8:15 PM
NetApex
Using octane
Mark M.
in that case, that's an HTML/JS issue, to size the embed
octane?
NetApex
Err... Iframe
Stupid auto correct
Mark M.
ha!
thought maybe it was some JS YouTube library :-)
NetApex
Hehe
Ok I will look into that then
Mark M.
if you are truly using WebView, you could also feed some JS code the screen size via loadUrl("javascript:...")
or have the JS pull it via addJavascriptInterface()
if you're showing this in a browser, though, those won't be options
NetApex
Would that account for tablets vs phones
Mark M.
would what account for tablets vs phones?
NetApex
The Javascript, would I be able to size differently for phones vs tablets?
Mark M.
well, again, it's a question of how you're getting the screen size
is this WebView, or a browser?
you mentioned WebView before, I'm just confirming
NetApex
With the octane you can define a size, but one size doesn't fit all obviously, and I can't find a "if HE then this size" easy method
It's webview
Mark M.
is this WebView, or a browser?
ok
8:20 PM
Mark M.
then, if you can't find a pure HTML/JS way to find the screen size, I'd use addJavascriptInterface() and give JS the means to find the screen size
then, your JS can modify the DOM to size your iframe appropriately
NetApex
I am guessing that is how the market does their app preview views
Mark M.
beats me
NetApex
Seems logical at least
There is always something new to learn it seems
Mark M.
good thing, too
it helps with book sales
:-)
NetApex
True
Lol
Thanks again
Mark M.
no problem, happy to help
NetApex
Working on my first "important" app
Mark M.
don't say that so loud -- your other apps might hear you
NetApex
Lol, they know they were just for fun
8:25 PM
NetApex
Off to learn some JS screen size finding
Mark M.
yeah, that part's outside my skill set\
I rely on stuff like GWT or ExtJS or something to figure that out
NetApex
I will write up a chapter for ya to include in your next book update. :)
Gwt...that sounds like an idea
Mark M.
there was a presentation on GWT-for-mobile at 2011 Google I|O
haven't watched the video yet
NetApex
I will tonight
Trying to work this for tablets and phones is new to me
Which book goes over fragments?
Mark M.
introductory stuff in BCG to Android App Development
dynamic fragments (transactions) in the Advanced Android one
NetApex
Going to be a long night of reading and videos
8:30 PM
Mark M.
well, I'll let you get to it then, as it's time to put the chat to bed
next one 4pm on Monday
NetApex
Take care man
Ok
Mark M.
(Eastern)
have a pleasant evening!
NetApex
has left the room
Mark M.
turned off guest access

Tuesday, September 27

 

Office Hours

People in this transcript

  • Bill Bejeck
  • Mark Murphy
  • NetApex
  • Rich Friedel