Sunday 15 June 2014

java - Android intent creating new instance of object -


I am passing a serializable object from an activity using an intent, but when I print object.toString ) After the object is inserted into the intent of A and after recovered in B, I think that they are actually different examples.

The problem here is that I have the area of ​​that object in a different class and different thread, and as long as I put objects in a purpose in Activity A., those fields are not ready yet, but By the time I retrieve them they are ready. However, when I tried to retrieve those areas in Activity B, I saw that they were empty because the recovered object was a new example.

How can I solve this problem? I do not know how to make the main thread until the object-initialization function is finished (the thread is already tried. Join ()). I basically have to send only two activities from one activity to another, except when I am sending them (i.e. putting them in an intention), they are empty, but when they are being received they are already Are populated.

There are two scenarios which I could think about:

  • Your activity can run without information, trying to send it through intent, this situation In Activity B, one can register your thread and, once finished, can transmit data through
  • Your activity can be operated without that data and activity. Runs that generate that data eg Work B starts in one and in the beginning of work B (which will be in onPostExecute () method).

No comments:

Post a Comment