我有一个实现可序列化的类。
当我将该类中的一个对象添加到 Intent extra 和午餐活动时,我没有问题。
但是当我尝试将对象添加到通知栏中的 PedingIntent 午餐的 Intent 时,我收到以下错误:
08-08 18:20:06.186: E/AndroidRuntime(1332): java.lang.RuntimeException: Parcelable encountered IOException writing serializable object
这是我的代码:
this.tickerText = sender.getName() + " Sent you a new message";
CharSequence contentTitle = "New message from " + sender.getName();
CharSequence contentText = "Click to open";
Intent chat = new Intent(context, Chat.class);
chat.putExtra(app.EXTRA_FACEBOOKUSER, sender);
chat.putExtra(app.EXTRA_RESET_WAINTING_CHAT_MESSAGES, true);
PendingIntent intent = PendingIntent.getActivity(context, 0, chat, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
this.setLatestEventInfo(context, contentTitle, contentText, intent);
发件人变量类:
import java.io.Serializable;
import android.graphics.drawable.Drawable;
public class FacebookUser implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String name, gender, status;
private int id;
private double distance, longitude, latitude;;
private Drawable profilePicture;
private boolean isFacebookFriend = false;
public FacebookUser() {
}
public FacebookUser(int id, String name) {
this.setId(id);
this.setName(name);
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public Drawable getProfilePicture() {
Drawable picture = profilePicture;
if (picture != null)
picture = profilePicture.getConstantState().newDrawable();
return picture;
}
public void setProfilePicture(Drawable profilePicture) {
this.profilePicture = profilePicture;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public double getDistance() {
return distance;
}
public void setDistance(double distance) {
this.distance = distance;
}
public boolean isFacebookFriend() {
return isFacebookFriend;
}
public void setFacebookFriend(boolean isFacebookFriend) {
this.isFacebookFriend = isFacebookFriend;
}
public String toString()
{
return this.name;
}
}