-1

How do you pass an object between views in an android application. I have googled and found that your class needs to implement the appropriate interface. How though do we do it if we do not own the class/object type we are passing (for example from an external library or a random class within the sdk)

I need to pass a HtmlSelect item object (from HtmlUnit open source project) to another class to process it but I cant bundle it up.

Thanks

Biscuit128
  • 5,218
  • 22
  • 89
  • 149
  • 2
    there are posts on SO that discuss this. http://stackoverflow.com/questions/2906925/android-how-do-i-pass-an-object-from-one-activity-to-another – Orlymee Jun 22 '12 at 15:31

2 Answers2

1

My best guess is you create a static helper object and pass it like that.

HelperObject class {
    static HtmlSelect myHtmlObject
}

source activity:

HelperObject.myHtmlObject = currentHtlmlObject;
startActivity(intent);

Destination activity:

onCreate() {
    HtmlSelect htmlSelect = "create a copy copy of HelperObject.myHtmlObject not to have problems and then set it to null"
}
Nuno Gonçalves
  • 6,202
  • 7
  • 46
  • 66
-1

Just use the putExtra() method of your Intent to pass parameters.

At times you need to first "deconstruct" your object into simple elements (Strings, Integers) and then reconstitute it at the other end with getExtras().

Mundi
  • 79,884
  • 17
  • 117
  • 140