我已经使用扩展RuntimeException实现了 VariosItensEncontradosException.java ,当它调用时,我保存项目,然后调用活动列出这些项目。我的问题是当我开始活动时采取一个例外。
Class Exception
public class VariosItensEncontradosException extends RuntimeException {
private final List<Item> itens;
public VariosItensEncontradosException(List<Item> itens) {
super("Vários lotes encontrados para o código informado");
this.itens = itens;
}
public List<Item> getItens() {
return itens;
}
}
我的物品
public final class Item implements Parcelable, Serializable {
private String codigo;
private String descricao;
private transient BigDecimal fatorConversao;
protected Item(Parcel in) {
codigo = in.readString();
descricao = in.readString();
fatorConversao = new BigDecimal(in.readString());
}
public static final Creator<Item> CREATOR = new Creator<Item>() {
@Override
public Item createFromParcel(Parcel in) {
return new Item(in);
}
@Override
public Item[] newArray(int size) {
return new Item[size];
}
};
public String getCodigo() {
return codigo;
}
public String getDescricao() {
return descricao;
}
public BigDecimal getFatorConversao() {
return fatorConversao;
}
public String descricao() {
return String.format("%s - %s", getCodigo(), getDescricao());
}
@Override
public int describeContents() {
return hashCode();
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(codigo);
parcel.writeString(descricao);
parcel.writeString(fatorConversao.toString());
}
}
我称之为新活动的方式
catch (VariosItensEncontradosException ex) {
edtBarcode.setText("");
SelecionarItemActivity.show(getActivity(), ex.getItens(), this);
我的意外
致命例外:主要流程: android.modulo38.winthor.pcsist.com.br.modulo38,PID:23067 java.lang.RuntimeException:Parcelable遇到IOException写入 可序列化对象(name = br.com.pcsist.winthor.modulo38.mobile.ui.expedicao.separacao.menu.item.ItemSeparacaoFragment) 在android.os.Parcel.writeSerializable(Parcel.java:1527)at android.os.Parcel.writeValue(Parcel.java:1475)at android.os.Parcel.writeArrayMapInternal(Parcel.java:724)at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)at at android.os.Bundle.writeToParcel(Bundle.java:1157)at android.os.Parcel.writeBundle(Parcel.java:764)at android.content.Intent.writeToParcel(Intent.java:8694)at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3082) 在 android.app.Instrumentation.execStartActivity(Instrumentation.java:1520) 在android.app.Activity.startActivityForResult(Activity.java:4266)at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:54) 在 android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75) 在android.app.Activity.startActivityForResult(Activity.java:4224)at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:708) 在android.app.Activity.startActivity(Activity.java:4563)at android.app.Activity.startActivity(Activity.java:4531)at br.com.pcsist.winthor.modulo38.mobile.ui.expedicao.selecionar_item.SelecionarItemActivity.show(SelecionarItemActivity.java:54) 在 br.com.pcsist.winthor.modulo38.mobile.ui.expedicao.separacao.menu.item.ItemSeparacaoFragment.separar(ItemSeparacaoFragment.java:201) 在 br.com.pcsist.winthor.modulo38.mobile.ui.expedicao.separacao.menu.item.ItemSeparacaoFragment.separar(ItemSeparacaoFragment.java:156) 在 br.com.pcsist.winthor.modulo38.mobile.ui.expedicao.separacao.menu.item.ItemSeparacaoFragment_ViewBinding $ 3.onEditorAction(ItemSeparacaoFragment_ViewBinding.java:65) 在android.widget.TextView.onEditorAction(TextView.java:4903)处 com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:138) 在 com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:372) 在 com.android.internal.view.IInputConnectionWrapper $ MyHandler.handleMessage(IInputConnectionWrapper.java:93) 在android.os.Handler.dispatchMessage(Handler.java:102)at android.os.Looper.loop(Looper.java:154)at android.app.ActivityThread.main(ActivityThread.java:6130)at java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:886) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)引起 by:java.io.NotSerializableException: android.support.v7.widget.AppCompatEditText at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1224) 在 java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1584) 在 java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1549) 在 java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1472) 在 java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1218) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346) 在android.os.Parcel.writeSerializable(Parcel.java:1522)at android.os.Parcel.writeValue(Parcel.java:1475)at android.os.Parcel.writeArrayMapInternal(Parcel.java:724)at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)at at android.os.Bundle.writeToParcel(Bundle.java:1157)at android.os.Parcel.writeBundle(Parcel.java:764)at android.content.Intent.writeToParcel(Intent.java:8694)at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3082) 在 android.app.Instrumentation.execStartActivity(Instrumentation.java:1520) 在android.app.Activity.startActivityForResult(Activity.java:4266)at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:54) 在 android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75) 在android.app.Activity.startActivityForResult(Activity.java:4224)at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:708) 在android.app.Activity.startActivity(Activity.java:4563)at android.app.Activity.startActivity(Activity.java:4531)at br.com.pcsist.winthor.modulo38.mobile.ui.expedicao.selecionar_item.SelecionarItemActivity.show(SelecionarItemActivity.java:54) 在 br.com.pcsist.winthor.modulo38.mobile.ui.expedicao.separacao.menu.item.ItemSeparacaoFragment.separar(ItemSeparacaoFragment.java:201) 在 br.com.pcsist.winthor.modulo38.mobile.ui.expedicao.separacao.menu.item.ItemSeparacaoFragment.separar(ItemSeparacaoFragment.java:156) 在 br.com.pcsist.winthor.modulo38.mobile.ui.expedicao.separacao.menu.item.ItemSeparacaoFragment_ViewBinding $ 3.onEditorAction(ItemSeparacaoFragment_ViewBinding.java:65) 在android.widget.TextView.onEditorAction(TextView.java:4903)处 com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:138) 在 com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:372) 在 com.android.internal.view.IInputConnectionWrapper $ MyHandler.handleMessage(IInputConnectionWrapper.java:93) 在android.os.Handler.dispatchMessage(Handler.java:102)at android.os.Looper.loop(Looper.java:154)