对象是非常有用的,因为可以通过在意图的演员:公司的FireStore如何使用的GeoPoint
Intent intent = new Intent(this, SomeActivity.class);
intent.putExtra("key", someObject);
startActivity(intent);
然后把它在其他活动:
MyObjectUsinGeoPoint Object = (MyObjectUsinGeoPoint) getIntent().getSerializableExtra("key");
问题是,我得到这个错误:
Caused by: java.io.NotSerializableException: com.google.firebase.firestore.GeoPoint
我尽量让GeoPoint
impleme NTS Serializable
我的模型内部创建一个内部类:
private class GeoBetter extends GeoPoint implements Serializable {
public GeoBetter(double v, double v1) {
super(v, v1);
}
}
然后初始化它在构造函数中:
public MyObjectUsinGeoPoint(double latitude, double longitude) {
geoPoint = new GeoBetter(latitude, longitude);
}
但我得到这个其他错误:
Caused by: java.io.InvalidClassException: com.domain.tupas.models.MyObjectUsinGeoPoint$GeoBetter; no valid constructor
我怎么能为包含不可序列化的对象的Intent额外添加?
似乎它可以工作,你能分享完整的课程和几个例子吗? – cutiko
这里你去:https://gist.github.com/adityahas/7729153e522e2c6d184aa641d070aef1 你特别需要什么样的例子? –
那么模型似乎是自我解释,我会尝试它,让你知道,请耐心等待,我目前在其他项目 – cutiko