Guest User

Untitled

a guest
Jun 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. CustomListing currentListing = new CustomListing();
  2. Intent i = new Intent();
  3. Bundle b = new Bundle();
  4. b.putParcelable(Constants.CUSTOM_LISTING, currentListing);
  5. i.putExtras(b);
  6. i.setClass(this, SearchDetailsActivity.class);
  7. startActivity(i);
  8.  
  9. Bundle b = this.getIntent().getExtras();
  10. if (b != null)
  11. mCurrentListing = b.getParcelable(Constants.CUSTOM_LISTING);
  12.  
  13. class Myclass {
  14. int a;
  15. class SubClass {
  16. int b;
  17. }
  18. }
  19.  
  20. MyClass src = new MyClass();
  21. Gson gS = new Gson();
  22. String target = gS.toJson(src); // Converts the object to a JSON String
  23.  
  24. Intent i = new Intent(FromActivity.this, ToActivity.class);
  25. i.putExtra("MyObjectAsString", target);
  26.  
  27. String target = getIntent().getStringExtra("MyObjectAsString");
  28. MyClass src = gS.fromJson(target, MyClass.class); // Converts the JSON String to an Object
  29.  
  30. public class PersonHelper
  31. {
  32. public static Person person;
  33. }
Add Comment
Please, Sign In to add comment