Jul 16 | 3:50 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jul 16 | 4:00 PM |
EGHDK | has entered the room |
Mark M. |
hello, EGHDK
|
Mark M. |
how can I help you today?
|
EGHDK |
View paste
|
EGHDK |
I'm going to pastebin my sample app activity code
for just Video and Gallery, I was wondering if you could see if there is
anything wrong with it.
|
EGHDK | |
Mark M. |
well, you aren't doing anything with the results
|
Mark M. |
what specifically does "a really tough time" mean?
|
EGHDK |
If you could just look at the intents first I
guess. Because I keep getting a null response from these two intents. I
realize my onActivityResult is omitted for now. Just wanted to get a
quick diagnosis with the intents.
|
Mark M. |
what do you mean by "a null response"?
|
EGHDK |
Okay, I guess I will post my onActivityResult. Give me one second.
|
Jul 16 | 4:05 PM |
Mark M. |
that's a mighty long second :-)
|
Jul 16 | 4:10 PM |
EGHDK |
That's what I'm sayin... I'm trying to pull out my
other code so it's clear. But I'm also testing it really quickly to
make sure it's not magically working.
|
Mark M. |
could you perhaps just explain, in words, what you mean by "a null response"?
|
Mark M. |
I'm not asking to see your onActivityResult() implementation
|
EGHDK |
Okay so I basically do this with the video Result
|
EGHDK | |
Jul 16 | 4:15 PM |
EGHDK |
I always get the Toast to show. So `intent.getData()` get's returned as null...
|
Jul 16 | 4:15 PM |
Mark M. |
and you are checking that resultCode is ACTIVITY_OK first?
|
EGHDK |
Yep
|
Mark M. |
then your particular test device's video recording app does not appear to be following the ACTION_VIDEO_CAPTURE contract
|
Mark M. |
you might try switching to passing in a location via EXTRA_OUTPUT and see if that helps
|
EGHDK |
BUT, my biggest issue is that Google has a sample
app for getting this, but yet it doesn't work on my phone either. It
returns null.
|
EGHDK |
I have stock android running on my gnex, and the stock camera app is running.
|
EGHDK |
"you might try switching to passing in a location
via EXTRA_OUTPUT and see if that helps" can you explain. I'm not sure
what that means.
|
Mark M. | |
Mark M. |
"The caller may pass in an extra EXTRA_OUTPUT to
control where the video is written. If EXTRA_OUTPUT is not present the
video will be written to the standard location for videos, and the Uri
of that location will be returned in the data field of the Uri."
|
Mark M. |
you are relying on the behavior in the second quoted sentence
|
Mark M. |
I'm suggesting that you try the first quoted sentence and see if that proves more reliable
|
Mark M. |
in general, though, any time you are asking a third-party app to do something, the app may not completely comply
|
Mark M. |
I would expect Google's own camera app to behave properly
|
EGHDK |
Yeah... I thought it was my code that was broken...
|
Mark M. |
but, Google can have bugs just as much as anyone else
|
Mark M. |
not in any obvious fashion
|
Jul 16 | 4:20 PM |
EGHDK |
And then I looked in your book and I was like what!? Theres no guide to taking video?
|
EGHDK |
Hahaha
|
Mark M. |
actually, you'll get some of that in the next update
|
Mark M. |
however, my focus is more on taking photos and video yourself
|
Mark M. |
versus relying on potentially-shaky third-party apps
|
EGHDK |
But I guess this output thing will be a good start. It's just weird because getting data from camera intent works fine.
|
Mark M. |
taking the videos yourself has its own set of challenges, though
|
EGHDK |
"focus on taking photos and video yourself" YES PLEASE
|
EGHDK |
Can't wait for that update. Version 5.0 you think?
|
Mark M. |
yes, presently scheduled for release on Monday
|
Mark M. |
in terms of the images, that too looks OK, though I have never tried ACTION_PICK on that particular CONTENT_URI before
|
Mark M. |
you could go with ACTION_GET_CONTENT and image/* for a MIME type as an alternative
|
Jul 16 | 4:25 PM |
EGHDK |
Where are you reading that?
|
Mark M. |
where am I reading what?
|
EGHDK |
ACTION_GET_CONTENT
|
Mark M. | |
EGHDK |
Okay cool. I'll look into that too. This is getting interesting. I thought this would have been a bit simpler.
|
Mark M. |
if it were simpler, you wouldn't need to subscribe to balding guys' books, now, would you? :-)
|
EGHDK |
Hey, baldy knows what he's talking about.
|
EGHDK |
Hahah. You've got a lot of experience with this. And with that comes wisdom.
|
EGHDK |
It's more like a 40 dollar book of wisdom.
|
Mark M. |
bad news, though
|
EGHDK |
What?
|
Mark M. |
the price went up to $45 back in January
|
EGHDK |
Eh. $45 dollar book of wisdom. I wish other books I bought came with updates...
|
EGHDK |
Went into the store the other day, and saw a few android dev books. Picked em up. Most were priced at like 50-60 bucks. No way.
|
Jul 16 | 4:30 PM |
EGHDK |
Oh! Quick question. Is there any place you know of
that will print this pdf for me? I could sure use it in print. I've
looked online but no one really prints in the thousands of pages. lol
|
Mark M. |
I would assume FedEx Office, Staples, etc. would do it, via their online print ordering stuff
|
Mark M. |
the size of the PDF file might be more of an issue than the page count
|
Mark M. |
and then you'd need a bunch of three-ring binders or something
|
Mark M. |
I make the PDF specifically be printable
(particularly double-sided), but that's usually impractical at the level
of the entire book
|
Mark M. |
individual chapters are more realistic
|
EGHDK |
Yep. Alright so my next problem is with gallery.
|
EGHDK |
Here is my onResult
|
EGHDK | |
EGHDK |
So my gallery shows up, and I get my Android folder to choose from (Camera, Screenshots, GroupMe)
|
Jul 16 | 4:35 PM |
EGHDK |
If I choose a screenshot or a groupme picture, I get a Toast "1" and a toast "2".
|
EGHDK |
If I choose a picture from my camera folder, the screen goes black for like 10 seconds, and doesn't toast anything.
|
EGHDK |
Can't figure that out.
|
Mark M. |
once again, the problem would appear to be with the camera app, not your code
|
EGHDK |
It's coming from the stock gallery app
|
Mark M. |
what do you intend to do with the image once you get it?
|
Jul 16 | 4:40 PM |
EGHDK |
View paste
|
EGHDK |
I intend to display a little icon of it, and possibly join it with another image.
|
Mark M. |
again, the problem isn't with your code
|
EGHDK |
But I can't do anything If I can't get half of the images in my gallery.
|
EGHDK |
You think it's a memory problem?
|
Mark M. |
and that's a problem with the gallery app
|
Mark M. |
wait
|
Mark M. |
do you actually get a chance to choose the image in the gallery app?
|
EGHDK |
Yeah
|
Mark M. |
hmmmm...
|
EGHDK |
It only hangs when I choose the specific image in the folder I specified.
|
Mark M. |
I would recommend switching to LogCat (via Log.d() and such) rather than toasts, so you are sure that you do not miss anything
|
Mark M. |
the memory issue would only come up if you actually tried loading the image, which would imply that you got past your "1" toast
|
EGHDK |
And it hangs right when I touch the image. So it's the gallery app that's actually "hanging"
|
Jul 16 | 4:45 PM |
Mark M. |
and if that's the case, the problem is in the gallery app
|
EGHDK |
Okay, I'll accept it. lol Thanks.
|
Mark M. |
there's nothing you can really do that should screw up another app in this fashion
|
Mark M. |
but, again, try using LogCat instead of toasts
|
EGHDK |
Yep.
|
Mark M. |
or use breakpoints
|
Mark M. |
it may be that you actually *are* getting control back, but things are visually stuck
|
Mark M. |
it is well within reason that you will encounter memory issues with your current implementation, though
|
EGHDK |
How would I check that?
|
Mark M. |
if you get a log message for "1", then you got to that line
|
Mark M. |
or, if you hit a breakpoint where you are presently toasting "1", you got to that line
|
EGHDK |
True. Okay I will try that.
|
EGHDK |
Okay, two more questions!
|
EGHDK |
One is a sample app that I made that I don't get how it's working.
|
Mark M. |
because you're really really good
|
Mark M. |
:-)
|
EGHDK |
Okay so I have a very simple app. Two activities. MainActivity has one button, and SecondActivity has an textView.
|
EGHDK |
When I click the button I go to the secondActivity.
|
Jul 16 | 4:50 PM |
EGHDK |
When I'm in the second activity and press the home button, my overriden onStop method get's called.
|
EGHDK |
My onStop method set's the text of the textView
|
EGHDK |
When I get back to my app, from recent apps, I see the text has been changed.
|
EGHDK |
Why is that?
|
Mark M. |
because you changed the text
|
Mark M. |
and onStop() is called when the activity is no longer visible
|
EGHDK |
So Sorry onstop() I set a String variable to a value.
|
EGHDK |
On resume I setText to the variable.
|
EGHDK |
I didn't know variables stay alive when you leave an activity?
|
Mark M. |
data members of an object live as long as the object dos
|
Mark M. |
er, does
|
Mark M. |
your activity was not destroyed
|
Mark M. |
it was just moved to the background
|
Mark M. |
and your process was not terminated between the time you pressed HOME and the time you went back to the activity
|
Mark M. |
hence, the data member is still there
|
EGHDK |
Okay, so I reload the application on my phone.
|
EGHDK |
SO everything is gone.
|
EGHDK |
Now, I press the button on mainActivity
|
EGHDK |
but then I press the back button
|
EGHDK |
onStop() get's called.
|
EGHDK |
And I'm back at the MainActivity.
|
EGHDK |
I press the button again. I don't see my textView set.
|
Mark M. |
correct
|
EGHDK |
That's because I created a totally new "SecondActivity" correct?
|
Mark M. |
correct
|
EGHDK |
So on the Intent, I tried doing setFlags
|
EGHDK |
FLAG_ACTIVITY_REOERDER_TO_FRONT
|
Jul 16 | 4:55 PM |
EGHDK |
Reading the documentation, I should get the result I want. (textView is set to variable)
|
Mark M. |
on *what* Intent?
|
EGHDK |
On the intent created by the button press on the MainActivity
|
EGHDK |
Basically, once I start my secondActivity, i want to keep back going to it.
|
Mark M. |
then you have to do something to change the BACK button behavior
|
EGHDK |
REORDER_TO_FRONT should have done the trick... no?
|
Mark M. |
no
|
Mark M. |
why would it?
|
Mark M. |
BACK destroys the activity
|
Mark M. |
period
|
Mark M. |
end of story, by default
|
EGHDK |
Really?
|
EGHDK |
Wait wait wait.
|
EGHDK |
Why didn't I know this.
|
EGHDK |
Oh man.
|
EGHDK |
So back calls finish?
|
Mark M. |
effectively, yes
|
EGHDK |
"effetively"?
|
EGHDK |
effectively*
|
Mark M. |
well, there are a few more steps between pressing BACK and finish() being called
|
EGHDK |
Where would I go to see what the back button actually does?
|
Mark M. |
and I'm not 100% certain if finish() is literally called, or something else is called that does the same thing
|
Mark M. |
hang on
|
Jul 16 | 5:00 PM |
Mark M. |
the primary entry point into your app for BACK presses is onBackPressed()
|
Mark M. |
(there should also be some calls to onKeyEvent() and such, and I'm not sure of the precise timing of those)
|
EGHDK |
Okay. Sweet. Alright, so finish() destroys an
activity, and back buttons destorys the activity. But back does not
necessarily call finish.
|
Mark M. |
the default implementation of onBackPressed() will
call finish() if there are no outstanding FragmentTransactions on the
back stack
|
Mark M. | |
EGHDK |
onBackPressed can't be used on fragments right
|
Mark M. |
no, but a fragment created via a
FragmentTransaction, where the transaction has addToBackStack() called
on it, will be reversed on a BACK press
|
Mark M. |
and that's pretty much a wrap for today's chat
|
Mark M. |
next one is Thursday at 10am
|
EGHDK |
Alrighty O.
|
Mark M. |
the transcript of this one will show up at http://commonsware.com/office-hours/ shortly
|
EGHDK |
Cool. Learned a lot. Thanks Mark. I have one more question that I'll hold out till Thursday.
|
Mark M. |
have a pleasant day!
|
EGHDK |
You too.
|
EGHDK | has left the room |
Mark M. | turned off guest access |