3 回答

TA貢獻1869條經(jīng)驗 獲得超4個贊
可序列化
CustomListing currentListing = new CustomListing();Intent i = new Intent(); Bundle b = new Bundle();b.putParcelable(Constants.CUSTOM_LISTING, currentListing); i.putExtras(b);i.setClass(this, SearchDetailsActivity.class);startActivity(i);
Bundle b = this.getIntent().getExtras();if (b != null) mCurrentListing = b.getParcelable(Constants.CUSTOM_LISTING);

TA貢獻1719條經(jīng)驗 獲得超6個贊
getApplication()
.

TA貢獻1862條經(jīng)驗 獲得超6個贊
class Myclass { int a; class SubClass { int b; }}
MyClass src = new MyClass();Gson gS = new Gson();String target = gS.toJson(src); // Converts the object to a JSON String
Intent i = new Intent(FromActivity.this, ToActivity.class);i.putExtra("MyObjectAsString", target);
String target = getIntent().getStringExtra("MyObjectAsString");MyClass src = gS.fromJson(target, MyClass.class); // Converts the JSON String to an Object
更新
Eventbus
奧托
添加回答
舉報