[android-developers] Re: passing arrays between classes using intent

2011-03-14 Thread A. Elk
Is this a trick question? Some web app protocols do this! I admit that
they're way out of date, but that design pattern is still around
haunting us.

Storing state data for a web app is not always that easy.

Fortunately, Android can handle this better than some old web
frameworks. A database is a good solution, especially since they're
relatively easy to set up.

On Mar 13, 6:16 am, Mark Murphy  wrote:
> On Sun, Mar 13, 2011 at 8:49 AM, Chetan Singh Bisht
>
>  wrote:
> > hi, i am developing a final year project where i need to retrieve
> > details of hospitals like name ,address, location(in terms of latitude
> > and longitude) from a server and display them on a mapconnectivity
> > has been established and i am able to retrieve the values in the from
> > of array like address[], name[] etc..
>
> > now i need to pass these values from an activity class to map activity
> > class..
>
> What you really need is a central spot to hold that data, such as a database.
>
> Think of a Web app. Would you pass the entire contents of your
> "details of hospitals" in GET parameters from one Web page to another?
> Or would you hold the "details of hospitals" in a central place (Web
> server) and use the data from both pages?
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android 3.0 Programming Books:http://commonsware.com/books

-- 
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


[android-developers] Re: passing arrays between classes using intent

2011-03-14 Thread Kamil
I think, you could use JSONArray to store data, convert JSON array to
string and put it into extras. It's only way how to do it.
Another way is to store arrays in different singleton object/static
class or put data into SQLite database and read from other activity
but it is not using Intent.

On 13 Mar, 14:16, Mark Murphy  wrote:
> On Sun, Mar 13, 2011 at 8:49 AM, Chetan Singh Bisht
>
>  wrote:
> > hi, i am developing a final year project where i need to retrieve
> > details of hospitals like name ,address, location(in terms of latitude
> > and longitude) from a server and display them on a mapconnectivity
> > has been established and i am able to retrieve the values in the from
> > of array like address[], name[] etc..
>
> > now i need to pass these values from an activity class to map activity
> > class..
>
> What you really need is a central spot to hold that data, such as a database.
>
> Think of a Web app. Would you pass the entire contents of your
> "details of hospitals" in GET parameters from one Web page to another?
> Or would you hold the "details of hospitals" in a central place (Web
> server) and use the data from both pages?
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android 3.0 Programming Books:http://commonsware.com/books

-- 
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


[android-developers] Re: passing arrays between classes using intent

2011-03-14 Thread Chetan Singh Bisht
yes i am working with primitive data types...i have an integer array
and two string arrays(no object arrays as such)

-- 
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


[android-developers] Re: passing arrays between classes using intent

2011-03-13 Thread Jonathan Foley


Yes, provided your are working with arrays of primitives or Strings
Bundle will work just fine.

 However, a db solution as Mark suggests has a number of advantages.
Your network queries should be happening in the background such as a
Service. Once your service fetches the data and saves in the db then
it can just send an Intent to notify the Activity that the data is
ready to pickup. Your activity then queries the DB and gets a Cursor
on that data. I wouldn't suggest passing around big arrays or other
objects between activities. If something like a phone call or
orientation change happens at an unfortunate time, then poof there
goes the results of your network query and you might have to start
over.

Jonathan




On Mar 13, 11:08 am, TreKing  wrote:
> On Sun, Mar 13, 2011 at 7:49 AM, Chetan Singh Bisht 
> > wrote:
> > now i need to pass these values from an activity class to map
> > activity class..i have used bundle to pass variables but i have no clue how
> > to pass integer and string arrays and how to retrieve them in the
> > second class using bundle...
>
> > can anyone please provide codes or relevant links which may be helpful in
> > solving this problem using bundle
>
> Um ... have you looked at the Bundle class documentation? There are
> functions that are literally called putXArray and getXArray, where "X" is
> some type.
>
> --- 
> --
> 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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en