类定义
private class classSerial implements Serializable {
private static final long serialVersionUID = 1L;
String vString;
boolean vBool;
long vLong;
int vInt;
classSerial(){
//initialize members;
}
}
我仍然收到错误:
Caused by: java.io.NotSerializableException: com.example.....
当我writeObject
尝试FileOutputStream
对classSerial
.
根据我的阅读,我使用的数据类型, String
, boolen
,是. 所以,我不需要实现任何方法。long
int
Serializable
我在这里想念什么?
LOGCAT
09-16 19:58:26.170: W/dalvikvm(4278): threadid=1: thread exiting with uncaught exception (group=0x40018560)
09-16 19:58:26.201: E/AndroidRuntime(4278): FATAL EXCEPTION: main
09-16 19:58:26.201: E/AndroidRuntime(4278): java.lang.IllegalStateException: Could not execute method of the activity
09-16 19:58:26.201: E/AndroidRuntime(4278): at android.view.View$1.onClick(View.java:2165)
09-16 19:58:26.201: E/AndroidRuntime(4278): at android.view.View.performClick(View.java:2506)
09-16 19:58:26.201: E/AndroidRuntime(4278): at android.view.View$PerformClick.run(View.java:9112)
09-16 19:58:26.201: E/AndroidRuntime(4278): at android.os.Handler.handleCallback(Handler.java:587)
09-16 19:58:26.201: E/AndroidRuntime(4278): at android.os.Handler.dispatchMessage(Handler.java:92)
09-16 19:58:26.201: E/AndroidRuntime(4278): at android.os.Looper.loop(Looper.java:130)
09-16 19:58:26.201: E/AndroidRuntime(4278): at android.app.ActivityThread.main(ActivityThread.java:3835)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.lang.reflect.Method.invokeNative(Native Method)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.lang.reflect.Method.invoke(Method.java:507)
09-16 19:58:26.201: E/AndroidRuntime(4278): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
09-16 19:58:26.201: E/AndroidRuntime(4278): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
09-16 19:58:26.201: E/AndroidRuntime(4278): at dalvik.system.NativeStart.main(Native Method)
09-16 19:58:26.201: E/AndroidRuntime(4278): Caused by: java.lang.reflect.InvocationTargetException
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.lang.reflect.Method.invokeNative(Native Method)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.lang.reflect.Method.invoke(Method.java:507)
09-16 19:58:26.201: E/AndroidRuntime(4278): at android.view.View$1.onClick(View.java:2160)
09-16 19:58:26.201: E/AndroidRuntime(4278): ... 11 more
09-16 19:58:26.201: E/AndroidRuntime(4278): Caused by: java.io.NotSerializableException: com.example.testing.serialActivity
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1535)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1143)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:413)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1241)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
09-16 19:58:26.201: E/AndroidRuntime(4278): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
09-16 19:58:26.201: E/AndroidRuntime(4278): at com.example.testing.serialActivity.login(login_activity.java:277)
09-16 19:58:26.201: E/AndroidRuntime(4278): at com.example.testing.serialtest.login(serialtest.java:34)
09-16 19:58:26.201: E/AndroidRuntime(4278): ... 14 more