On 03/17/2010 04:17 PM, Mark Murphy wrote:
mike wrote:
Oh! You should take that up with Google then because that's their
HelloActivity example code. I didn't change a thing there. If it
causes trouble, it's probably endemic because Hello World is where
most beginners start.
Seriously?
I don't see a "Hello Activity" example on their site or in the samples/
directory of 2.1. I see "Hello World", but there's no constructors in
that activity. Can you point me to the URL with the instructions you
followed?
There's no question that in the samples there's some fairly awful stuff
lingering around, so this doesn't surprise me. If you can point me to
it, I'll file a bug.
I'm currently have the set as sdk 1.5, and as I mentioned to create the
bug example code I just created a project using Eclipse and it asked
for an example project to use which is the second step in the create
project wizard.
In any case, I found it... it's in the 1.5 and 2.0 HelloActivity in
samples/HelloActivity/...
I didn't even notice that there was an empty constructor there!
I think calling setContentView() outside of onCreate() is cumbersome and
inelegant, but, to each their own.
Why? Is there actually some sort of proscription against calling
setContentView more than once? I've been using it this way for the
last year and a half and have never had a problem except for this.
No firm proscription. I get nervous about memory leaks, and it's
seriously inefficient to, say, keep replacing the WebView rather than
reloading data with loadDataWithBaseURL().
I'm not replacing the WebView in the real code. That was only
to demonstrate the problem. The WebView(s) persist for a long
time, specifically so that I can switch between webapps and native
app views without having to reload the webview which is time
and network (hence battery) intensive.
| Also, in the hands of newcomers to Android, the technique lends itself
to apps with The One Big-Ass...Er, I Mean...The One True Activity rather
than implementing separate activities for different screens.
There's reasons for modularity and isolation, and reasons for not.
If you could control Intents like shell subprocess (eg, the moral
equivalent of ^Z %2), it would be plausible to do it that way, maybe
even better since its friendlier to the low memory reaper. But AFAIK
that's not possible. My understanding of Intents isn't especially good
though.
But that's the reason why I didn't consider this a "serious bug" -- it's
an issue *if* you use setContentView() the way you do. If you only call
setContentView() once per activity, up in onCreate(), you'd never know
there was a problem. But, there's something definitely strange going on
with WebView -- not terribly shocking given how frakkin' complex it must
be to slam together WebKit code and Android's input method framework.
I'm just surprised that it's not come up before... well, it *has*
come up before just no traction, I guess (it doesn't appear that
others filed a bug report on it). Maybe this is because everything
has devolved into game development :|
Mike
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en