我有一个使用DefaultHttpClient
对象执行 http 休息请求的类。我试图使用相同的 HttpClient 对象在不同的类中执行另一个请求,并尝试将我用作序列化对象的类传递给新活动。但是在运行时它会给出一个 java.io.NotSerializableException ,因为DefaultHttpClient
有没有一种方法可以将DefaultHttpClient
对象原样传递给我正在加载的下一个活动。
09-03 12:51:44.891: E/AndroidRuntime(32297): FATAL EXCEPTION: main
09-03 12:51:44.891: E/AndroidRuntime(32297): java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.hcp.hcpandroid.SSLAuthenticate)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.os.Parcel.writeSerializable(Parcel.java:1279)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.os.Parcel.writeValue(Parcel.java:1233)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.os.Parcel.writeMapInternal(Parcel.java:591)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.os.Bundle.writeToParcel(Bundle.java:1619)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.os.Parcel.writeBundle(Parcel.java:605)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.content.Intent.writeToParcel(Intent.java:6519)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1741)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1411)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.app.Activity.startActivityForResult(Activity.java:3351)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.app.Activity.startActivityForResult(Activity.java:3312)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.app.Activity.startActivity(Activity.java:3522)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.app.Activity.startActivity(Activity.java:3490)
09-03 12:51:44.891: E/AndroidRuntime(32297): at com.hcp.hcpandroid.MainLogIn.hcpLogIn(MainLogIn.java:67)
09-03 12:51:44.891: E/AndroidRuntime(32297): at com.hcp.hcpandroid.MainLogIn$1.onClick(MainLogIn.java:35)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.view.View.performClick(View.java:4128)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.view.View$PerformClick.run(View.java:17142)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.os.Handler.handleCallback(Handler.java:615)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.os.Handler.dispatchMessage(Handler.java:92)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.os.Looper.loop(Looper.java:213)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.app.ActivityThread.main(ActivityThread.java:4787)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.lang.reflect.Method.invokeNative(Native Method)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.lang.reflect.Method.invoke(Method.java:511)
09-03 12:51:44.891: E/AndroidRuntime(32297): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
09-03 12:51:44.891: E/AndroidRuntime(32297): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
09-03 12:51:44.891: E/AndroidRuntime(32297): at dalvik.system.NativeStart.main(Native Method)
09-03 12:51:44.891: E/AndroidRuntime(32297): Caused by: java.io.NotSerializableException: org.apache.http.impl.client.DefaultHttpClient
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1364)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:979)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1074)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1404)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
09-03 12:51:44.891: E/AndroidRuntime(32297): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
09-03 12:51:44.891: E/AndroidRuntime(32297): at android.os.Parcel.writeSerializable(Parcel.java:1274)
09-03 12:51:44.891: E/AndroidRuntime(32297): ... 24 more