Tuesday, March 27, 2012

[android-developers] Re: Re : passing data between activities

Hi Vivek
you have created Intent for starting activity and passed intent as
a parameter in startActivity(Intent) method
like this in A class

Intent intent = new Intent(this, B.class);
intent.putExtra("Voilation1"," USING CELLULAR PHONE WHILE
DRIVING(H)");
intent.putExtra("Place1","chetpet signal");
startActivity(intent);

And In Class B Retrieve values in onCreate() method like this

String strVoilation1 =
getIntent().getStringExtra("Voilation1");
String strPlace1 = getIntent().getStringExtra("Place1");

That's it
Or you can put the Serialized object or parceble object in the intent
in your case you have a list of object of Voilations and Places,
create a model class of it add each object in the ArrayList
and put ArrayList into Intent, since ArrayList implemented
serializable interface you can add it into intent.
And get serialized object from other activity as a key value object
from the intent.

Thanks & Regards
Animesh Sinha

On Mar 26, 3:53 pm, vivek elangovan <elangovan.vi...@gmail.com> wrote:
> Using DOMParser i m getting values and passing it to my IInd activity.In my
> IInd activity i need to display like this
>
> Violation : USING CELLULAR PHONE WHILE DRIVING(H)
>
> Place : chetpet signal
>
> Violation : WITHOUT HELMET
>
> Place : Tnagar signal
>
>
>
>
>
>
>
> On Monday, March 26, 2012 4:20:26 PM UTC+5:30, vivek elangovan wrote:
>
> > Hi,
> >       This is how my xml looks like
>
> > <remarks>
> >             <offense>
> >                 <violation>WITHOUT HELMET</violation>
> >                 <rule>177-A</rule>
> >                 <amnt>100</amnt>
> >                 <date>26-3-2012</date>
> >                 <place>chetpet signal</place>
> >             </offense>
> >             <offense>
> >                 <violation>USING CELLULAR PHONE WHILE
> > DRIVING(H)</violation>
> >                 <rule>177-H</rule>
> >                 <amnt>1000</amnt>
> >                 <date>20-3-2012 </date>
> >                 <place>Tnagar signal </place>
> >             </offense>
> >         </remarks>
>
> > On Monday, March 26, 2012 3:03:38 PM UTC+5:30, vivek elangovan wrote:
>
> >> hi members,
> >>                     I am having two activities in my project, In my Ist
> >> activity i m getting two values from my loop (for eg : Violation : WITHOUT
> >> HELMET and Violation : USING CELLULAR PHONE WHILE DRIVING(H) ) using
> >> putExtra i am passing these values to my IInd activity,what i need to
> >> display here is like this :
>
> >> violation : WITHOUT HELMET
> >> place : some place
>
> >> Violation : USING CELLULAR PHONE WHILE DRIVING(H)
> >> place : some place

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