我对Java相当陌生,似乎无法解决我收到的这个NotSerializableException
。我正在写一个对象给用户的SD卡,接下来我需要读回它。解决NotSerializableException
这是我的代码:
@Override
protected void createAndAttachView(int id, FrameLayout frame) {
//Read the panel from the memory
PanelWrapper pnl = (PanelWrapper) readObjectFromMemory(B4AHelper.getDirDefaultExternal(), "layout.frame");
//Add the view
frame.addView(pnl.getObject());
//Broadcast an intent to the user.
intent = new IntentWrapper();
intent.Initialize("createAndAttachView", "");
intent.PutExtra("id", id);
intent.PutExtra("message", "View Attached");
sendBroadcast(intent.getObject());
//Log - debugging
Log.i("B4A", "View attached!");
}
我使用的是从herereadObjectFromMemory
和writeObjectFromMemory
,这是错误:
Error Message: anywheresoftware.b4a.BALayout
Error Message: Read an exception; java.io.NotSerializableException: anywheresoftware.b4a.BALayout
Caused by: java.lang.NullPointerException
at com.rootsoft.standout.MostBasicWindow.createAndAttachView(MostBasicWindow.java:53)
at com.rootsoft.standout.StandOutWindow$Window.<init>(StandOutWindow.java:2213)
at com.rootsoft.standout.StandOutWindow.show(StandOutWindow.java:1416)
at com.rootsoft.standout.StandOutWindow.onStartCommand(StandOutWindow.java:716)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2359)
... 10 more
我想,如果是有可能解释为好尽可能我是相当新的,这可能也会帮助其他人。
看看这个解决方案。 http://stackoverflow.com/a/4552014/1395259 –
谢谢!但我仍然不知道在哪里必须将“瞬态”放在前面 – Verhelst