Sep 29 | 7:20 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Sep 29 | 7:35 PM |
Bill B. | has entered the room |
Bill B. |
HI Mark
|
Mark M. |
howdy, Bill!
|
Mark M. |
how can I help you today?
|
Bill B. |
I have a question about Instumented Testing and TouchUtils.drag methods
|
Mark M. |
oy
|
Mark M. |
I'll give it a shot, but I haven't used drag()
|
Sep 29 | 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
|
Bill B. |
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
|
Mark M. |
in your line of code, what is "this"?
|
Mark M. |
oh, never mind
|
Mark M. |
knightImage is an ImageView?
|
Bill B. |
the instance of ActivityInstrumentationTestCase2
|
Bill B. |
yes
|
Bill B. |
let me show you part of the stack trace
|
Mark M. |
I certainly wouldn't expect that error
|
Sep 29 | 7:45 PM |
Mark M. |
is it a case where other places dragViewBy() is working and it's not here?
|
Mark M. |
or does it fail for you everywhere?
|
Bill B. |
this is the only place i'm using it
|
Bill B. |
do you want to see the whole test method?
|
Mark M. |
is the activity actually on the screen when you are running the test?
|
Mark M. | |
Bill B. |
View paste
|
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!
|
Mark M. |
Bill: here's another one: http://stackoverflow.com/q/3214531/115145
|
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
|
Mark M. |
I don't know what to tell you
|
Mark M. |
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
|
Mark M. |
Rich: do you have a question?
|
Bill B. |
thanks for the help
|
Sep 29 | 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
|
Rich F. |
Does the Intent hold any information from the initial class? I looked and didn't see anywhere this information was
|
Rich F. |
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
|
Mark M. |
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.
|
Rich F. |
huh?
|
Rich F. |
OH nvm ok I see I think...
|
Mark M. |
Bill: do you have another question?
|
Sep 29 | 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)
|
Rich F. |
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
|
Mark M. |
what is your objective of the "needs to tell" part?
|
Sep 29 | 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)
|
Rich F. |
So it needs to be pretty immediate, this 'state' change... I found that broadcasting a message was unreliable
|
Rich F. |
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
|
Rich F. |
the visual
|
Mark M. |
ok, have the service use AppWidgetManager to update the app widget
|
Mark M. |
(directly or via your intermediate class, whatever)
|
Mark M. |
and use a boolean isRunning static data member for future AppWidgetProvider onUpdate() calls
|
Mark M. |
(assuming there are any)
|
Mark M. |
updating the activity could be by broadcast, or createPendingResult(), or Messenger, etc.
|
Sep 29 | 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
|
Mark M. |
it's how you are getting your RemoteViews to the home screen
|
Mark M. |
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
|
Rich F. |
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
|
Sep 29 | 8:10 PM |
Mark M. |
glad you like 'em!
|
Rich F. |
no, love them!
|
Rich F. |
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
|
Mark M. |
howdy, NetApex!
|
Rich F. | has left the room |
NetApex |
How are you?
|
Mark M. |
do you have a question?
|
NetApex |
Quick question
|
NetApex |
Embedding YouTube
|
NetApex |
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
|
Sep 29 | 8:15 PM |
NetApex |
Using octane
|
Mark M. |
in that case, that's an HTML/JS issue, to size the embed
|
Mark M. | |
Mark M. |
octane?
|
NetApex |
Err... Iframe
|
NetApex |
Stupid auto correct
|
Mark M. |
ha!
|
Mark M. |
thought maybe it was some JS YouTube library :-)
|
NetApex |
Hehe
|
NetApex |
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:...")
|
Mark M. |
or have the JS pull it via addJavascriptInterface()
|
Mark M. |
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
|
Mark M. |
is this WebView, or a browser?
|
Mark M. |
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
|
NetApex |
It's webview
|
Mark M. |
is this WebView, or a browser?
|
Mark M. |
ok
|
Sep 29 | 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
|
Mark M. |
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
|
NetApex |
There is always something new to learn it seems
|
Mark M. |
good thing, too
|
Mark M. |
it helps with book sales
|
Mark M. |
:-)
|
NetApex |
True
|
NetApex |
Lol
|
NetApex |
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
|
Sep 29 | 8:25 PM |
NetApex |
Off to learn some JS screen size finding
|
Mark M. |
yeah, that part's outside my skill set\
|
Mark M. |
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. :)
|
NetApex |
Gwt...that sounds like an idea
|
Mark M. |
there was a presentation on GWT-for-mobile at 2011 Google I|O
|
Mark M. |
haven't watched the video yet
|
NetApex |
I will tonight
|
NetApex |
Trying to work this for tablets and phones is new to me
|
NetApex |
Which book goes over fragments?
|
Mark M. |
introductory stuff in BCG to Android App Development
|
Mark M. |
dynamic fragments (transactions) in the Advanced Android one
|
NetApex |
Going to be a long night of reading and videos
|
Sep 29 | 8:30 PM |
Mark M. |
well, I'll let you get to it then, as it's time to put the chat to bed
|
Mark M. |
next one 4pm on Monday
|
NetApex |
Take care man
|
NetApex |
Ok
|
Mark M. |
(Eastern)
|
Mark M. |
have a pleasant evening!
|
NetApex | has left the room |
Mark M. | turned off guest access |