如何从 Parcelable 中解压 FIRebaseUser
所以我有一个代码,其中包含一个包含 FirebaseUser 的 User 类。现在我尝试通过 Intent 传递该类,但是尽管 FirebaseUser 有一个写入包的方法,但它没有静态 Creator,所以我找不到从包中解包的方法。
这是我的类的 writeToParcel 方法。
@Override
public void writeToParcel(Parcel dest, int flags) {
this.user.writeToParcel(dest, flags);
dest.writeInt(this.Role);
dest.writeString(this.Address);
dest.writeString(this.phoneNumber);
}
因此,在近一个月没有得到答案后,我选择切换到这个构造函数,这不是最好的方法,但已经足够了。
protected User(Parcel in) {
this.user = FirebaseAuth.getInstance().getCurrentUser();
this.Role = in.readInt();
this.Address = in.readString();
this.phoneNumber = in.readString();
this.docRef = FirebaseFirestore.getInstance().document(in.readString());
}
但如果有人找到我的问题的答案那就太棒了。
So I have a code that includes a User class that contains FirebaseUser. Now I am trying to pass the class through Intent but, although FirebaseUser has a method to write to the parcel, it doesn't have a static Creator so I can't find a method to unpack from the parcel.
here is the writeToParcel method of my class.
@Override
public void writeToParcel(Parcel dest, int flags) {
this.user.writeToParcel(dest, flags);
dest.writeInt(this.Role);
dest.writeString(this.Address);
dest.writeString(this.phoneNumber);
}
So after getting no answers in almost a month I chose to switch over to this constructor which is not the best way but it is enough.
protected User(Parcel in) {
this.user = FirebaseAuth.getInstance().getCurrentUser();
this.Role = in.readInt();
this.Address = in.readString();
this.phoneNumber = in.readString();
this.docRef = FirebaseFirestore.getInstance().document(in.readString());
}
But if someone finds an answer to my question it would be amazing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论