Pass reference between two activities

Put your problem here if it does not fit any of the other categories.

Pass reference between two activities

Postby john_attend » Fri May 28, 2010 9:54 am

Hi everybody! :-)

I am facing a matter coding my Android application which I have not been able to find its "proper" solution.

I would like to transfer an object to another Activity which has been launched by an Intent. I know that I can use the Bundle to do it using putString etc.

To transfer a custom object, I could use putSerializable or putParcelable...
But the problem is that those methods create a copy of the objects, and what I would like is to get THE object (so passing by reference).

Is there any other way (than create a static class with a reference to the object) to do that ?

Thanks in advance ;-)
john_attend
Freshman
Freshman
 
Posts: 4
Joined: Fri May 28, 2010 9:43 am

Top

Re: Pass reference between two activities

Postby the_alien » Fri May 28, 2010 12:57 pm

Afaik you can't put in a reference. Itents can be used to call activities in other processes. In order to do so they have to serialize the objects.
Last edited by the_alien on Fri May 28, 2010 3:28 pm, edited 1 time in total.
the_alien
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed May 19, 2010 11:53 am

Re: Pass reference between two activities

Postby anarche » Fri May 28, 2010 2:00 pm

As above afaik you cannot do this.

It was also seem to be a security hole if you could, since you could write an app that - in the background - opens the google browser and inserts a malware object..
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: Pass reference between two activities

Postby john_attend » Tue Jun 01, 2010 2:16 pm

That's what I thought, unfortunately... :-\
Thank you ! :)
john_attend
Freshman
Freshman
 
Posts: 4
Joined: Fri May 28, 2010 9:43 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 36 guests