Monday, September 26, 2011

Re: [android-developers] unmarshalling and premature alarm problems

On Mon, Sep 26, 2011 at 4:33 PM, John Goche <johngoche99@googlemail.com> wrote:
Now I see what you mean. So these bundle objects are better than parcels to pass things around. Still don't understand why parcelable isn't working since my process was still around when I called it in some cases.

Not sure - but even if you figure that out, you'll run into the issue I described. Honestly, best to just forget about custom Parcelable types, IMO.
 
Anyways, besides designing parcelable as a performance improvement over serializable I'm still puzzled by why the android team had to come up with both bundles and parcels and not just have say bundles.

Good question. I'd love to hear on that as well.
 
Also, if an application has a unique context, then does a context correspond to a process? I see context passed around as a parameter a lot, but don't understand exactly what I am passing and why. It seems to me I keep on passing the same thing around. Or does each activity have a different context. Please help coming to grips with these presumably simple concepts.

Each Activity *is* a different Context (see the inheritance hierarchy in the docs). What is it? The way I think about things named "context" (GL and GWT have the same concept) is "thingie that describes the environment you're running in, which provides and interface to that environment". On Android a Context is usually your primary gateway to the system APIs. It's more of an abstract concept than an true object.
 
Finally, I think as an alternative to using the Bundleable interface described below I think it is also possible to pass parameters around by storing them in an SQLite database since most applications will already have one. Any disadvantages with this alternative approach (which at least should work not only when the process is killed but also across reboots???)

I wouldn't call storing data in a database to retrieve later "passing parameters around".
I wouldn't say "most applications already have one". If an developer needs one, they'll make one in their app.

Primary disadvantage to this: I'd imaging saving to and reading from a DB will be considerably slower than putting that data in a Bundle. Not to mention the extra code to write to and read from the DB. There may also be concurrency considerations.

Besides that, these are two fundamentally different concepts: marshalling data vs storing and persisting it. You could certainly use a DB to "pass data" around, but I'll bet you'll regret it later.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment