【发布时间】:2012-08-23 12:48:08
【问题描述】:
我对 Java 还很陌生,我似乎无法解决收到的 NotSerializableException 问题。我正在向用户的 sdcard 写入一个对象,接下来我需要读回它。
这是我的代码:
@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!");
}
我正在使用来自here 的readObjectFromMemory 和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
我想知道是否有可能解释得尽可能好,因为我是新手,这也可能对其他人有所帮助。
【问题讨论】:
-
看看这个解决方案。 stackoverflow.com/a/4552014/1395259
-
谢谢!但我仍然不知道我必须在哪里把“瞬态”放在前面
标签: android