Tuesday, June 28, 2011

[android-developers] Saving "pointers" to object

Ok, I know pointers don't exist in Java, but I was wondering if there
is a way to mimic its behavior or any other mechanism that let me keep
the reference to an object when my activity restart from a softkill.

inside the onCreate of my activity I have something like that:

work= new workThread(....);

this class workThread is not really a thread but its contructor
instanciate a real thread, and everything works fine, till I change
the orientation or leave my app.

the original workThread is still running in background all the time to
keep a socket opened.

when I go back to the app the onCreate instanciate a whole new
workThread object and when it runs it throws an exception becouse the
socket is already opened.

I know how to use the onSaveInstanceStatus and the Bundle at onCreate
to restore non View variables. But, as far I know, I only can do this
for basic types like int, String, etc.

What I need to keep is the reference to the original "work" object
created on the very first onCreate.

There is a way to do that?

Thanks a lot for any help

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