dow*_*123 4 android serializable realm parcelable parceler
我有以下代码产生错误: Error:Parceler: Unable to find read/write generator for type io.realm.Realm for io.realm.RealmObject.realm
它没有工作extends RealmObject,但是我想使用Realm轻松地放入数据库.有没有办法驱逐RealmObject字段,只使用@Parcel的基本pojo字段?
@Parcel
public class Feed extends RealmObject{
int id;
public String text;
public String time_created;
String time_modified;
int comments_count;
int likes_count;
String feed_type;
int obj_id;
String image;
String user_name;
String user_earthmile_points;
boolean liked;
boolean commented;
boolean is_private;
String url;
int feed_creator_id;
}
Run Code Online (Sandbox Code Playgroud)
Vic*_*ani 14
编辑#2:实际上,我找到了一种让它工作的方法:).请参阅下面的更新答案.
编辑#1:当应用程序编译得很好时,它在尝试实际创建Parcel错误时崩溃:org.parceler.ParcelerRuntimeException: Unable to create ParcelableFactory for io.realm.FeedRealmProxy.Realm团队已正式承认目前无法Parcelable在RealmObjects 上实施.目前还不清楚是否/何时解决这个问题.
使用Parceler v0.2.16,您可以执行以下操作:
@RealmClass // required if using JDK 1.6 (unrelated to Parceler issue)
@Parcel(value = Parcel.Serialization.BEAN, analyze = { Feed.class })
public class Feed extends RealmObject {
// ...
}
Run Code Online (Sandbox Code Playgroud)
然后,使用Parcels.wrap(Feed.class, feed)而不是Parcels.wrap(feed)到处,否则您的应用程序将崩溃org.parceler.ParcelerRuntimeException: Unable to create ParcelableFactory for io.realm.FeedRealmProxy.
| 归档时间: |
|
| 查看次数: |
2784 次 |
| 最近记录: |