您好,登錄后才能下訂單哦!
遇到了一個難纏的問題,搜了N天的沒有解決:
07-02 15:40:25.415: D/LocateService(6711): onLocationChanged: AMapLocation location =Location[lbs 0.000000,0.000000 acc=0 t=?!? et=?!? {Bundle[{adcode=, citycode=, desc=}]}] 07-02 15:40:25.425: D/AMapLocateListener(6711): onLocationChanged: location = Location[lbs 0.000000,0.000000 acc=0 t=?!? et=?!? {Bundle[{adcode=, citycode=, desc=}]}] 07-02 15:40:25.475: I/AuthFailure(6711): INVALID_USER_SCODE 07-02 15:40:29.105: D/GatewayPresentor(6711): logout: component = push 07-02 15:40:29.105: D/GatewayComponent(6711): logout 07-02 15:40:29.105: W/GatewayComponent(6711): mLogged = false, mSender = com.autonavi.connector.clientsdk.Sender@432462d8 07-02 15:40:29.105: D/WorkOrderFragment(6711): onDetach 07-02 15:40:29.105: D/OrderFragment(6711): onDetach 07-02 15:40:29.115: D/GatewayPresentor(6711): login: component = push, accessKey = 2, userId = 2, token = 5ad04ba7-de02-4203-a077-a79581c89252 07-02 15:40:29.115: D/GatewayComponent(6711): login: accessKey = 2, userId = 2, token = 5ad04ba7-de02-4203-a077-a79581c89252 07-02 15:40:29.115: I/Sender(6711): 生成消息號:6166812093405200387 07-02 15:40:29.125: D/ReadableDatabaseHelper(6711): query: distinct = false, table = TWorkOrder, columns = null, selection = create_time >= datetime('2015-07-02 15:38:29'), selectionArgs = null, groupBy = null, having = null, orderBy = null, limit =null 07-02 15:40:29.125: D/OrderFragment(6711): onAttach 07-02 15:40:29.155: D/AndroidRuntime(6711): Shutting down VM 07-02 15:40:29.155: W/dalvikvm(6711): threadid=1: thread exiting with uncaught exception (group=0x4173cd58) 07-02 15:40:29.155: E/AndroidRuntime(6711): FATAL EXCEPTION: main 07-02 15:40:29.155: E/AndroidRuntime(6711): Process: com.autonavi.taoparking.parker, PID: 6711 07-02 15:40:29.155: E/AndroidRuntime(6711): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.autonavi.taoparking.parker/com.autonavi.taoparking.parker.ManageOrderActivity}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.HorizontalScrollView$SavedState 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2190) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2239) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3730) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.ActivityThread.access$900(ActivityThread.java:141) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.os.Handler.dispatchMessage(Handler.java:102) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.os.Looper.loop(Looper.java:136) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.ActivityThread.main(ActivityThread.java:5047) 07-02 15:40:29.155: E/AndroidRuntime(6711): at java.lang.reflect.Method.invokeNative(Native Method) 07-02 15:40:29.155: E/AndroidRuntime(6711): at java.lang.reflect.Method.invoke(Method.java:515) 07-02 15:40:29.155: E/AndroidRuntime(6711): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806) 07-02 15:40:29.155: E/AndroidRuntime(6711): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622) 07-02 15:40:29.155: E/AndroidRuntime(6711): at dalvik.system.NativeStart.main(Native Method) 07-02 15:40:29.155: E/AndroidRuntime(6711): Caused by: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.HorizontalScrollView$SavedState 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.widget.HorizontalScrollView.onRestoreInstanceState(HorizontalScrollView.java:1659) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.view.View.dispatchRestoreInstanceState(View.java:12810) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2637) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2643) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2643) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.view.View.restoreHierarchyState(View.java:12788) 07-02 15:40:29.155: E/AndroidRuntime(6711): at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1744) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.Activity.onRestoreInstanceState(Activity.java:955) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.Activity.performRestoreInstanceState(Activity.java:927) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1138) 07-02 15:40:29.155: E/AndroidRuntime(6711): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168) 07-02 15:40:29.155: E/AndroidRuntime(6711): ... 12 more 07-02 15:40:31.695: I/Sender(6711): ..............發送心跳 07-02 15:40:31.825: I/Sender(6711): 重試連接到服務器 07-02 15:40:31.885: W/System.err(6711): java.net.ConnectException: failed to connect to /120.26.196.74 (port 10000): connect failed: ECONNREFUSED (Connection refused) 07-02 15:40:31.885: W/System.err(6711): at libcore.io.IoBridge.connect(IoBridge.java:114) 07-02 15:40:31.885: W/System.err(6711): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) 07-02 15:40:31.885: W/System.err(6711): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) 07-02 15:40:31.885: W/System.err(6711): at java.net.Socket.startupSocket(Socket.java:566) 07-02 15:40:31.885: W/System.err(6711): at java.net.Socket.tryAllAddresses(Socket.java:128) 07-02 15:40:31.885: W/System.err(6711): at java.net.Socket.<init>(Socket.java:178) 07-02 15:40:31.885: W/System.err(6711): at java.net.Socket.<init>(Socket.java:150) 07-02 15:40:31.885: W/System.err(6711): at com.autonavi.connector.clientsdk.ClientContext$1.run(ClientContext.java:74) 07-02 15:40:31.885: W/System.err(6711): at java.lang.Thread.run(Thread.java:841) 07-02 15:40:31.885: W/System.err(6711): Caused by: libcore.io.ErrnoException: connect failed: ECONNREFUSED (Connection refused) 07-02 15:40:31.885: W/System.err(6711): at libcore.io.Posix.connect(Native Method) 07-02 15:40:31.885: W/System.err(6711): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85) 07-02 15:40:31.885: W/System.err(6711): at libcore.io.IoBridge.connectErrno(IoBridge.java:127) 07-02 15:40:31.885: W/System.err(6711): at libcore.io.IoBridge.connect(IoBridge.java:112) 07-02 15:40:31.885: W/System.err(6711): ... 8 more 07-02 15:40:31.885: W/Sender(6711): failed to connect to /120.26.196.74 (port 10000): connect failed: ECONNREFUSED (Connection refused) 07-02 15:40:41.695: I/Sender(6711): ..............發送心跳 07-02 15:40:41.885: I/Sender(6711): 重試連接到服務器 07-02 15:40:41.945: W/GatewayComponent(6711): mLogAction = LOGIN, failure: code = -2004, message = 發送消息沒有回執確認 07-02 15:40:41.945: D/GatewayService(6711): mLocationLog.onFailed: code = -2004, message = 發送消息沒有回執確認 07-02 15:40:41.945: W/System.err(6711): java.net.ConnectException: failed to connect to /120.26.196.74 (port 10000): connect failed: ECONNREFUSED (Connection refused) 07-02 15:40:41.945: W/System.err(6711): at libcore.io.IoBridge.connect(IoBridge.java:114) 07-02 15:40:41.945: W/System.err(6711): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) 07-02 15:40:41.945: W/System.err(6711): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) 07-02 15:40:41.945: W/System.err(6711): at java.net.Socket.startupSocket(Socket.java:566) 07-02 15:40:41.945: W/System.err(6711): at java.net.Socket.tryAllAddresses(Socket.java:128) 07-02 15:40:41.945: W/System.err(6711): at java.net.Socket.<init>(Socket.java:178) 07-02 15:40:41.945: W/System.err(6711): at java.net.Socket.<init>(Socket.java:150) 07-02 15:40:41.945: W/System.err(6711): at com.autonavi.connector.clientsdk.ClientContext$1.run(ClientContext.java:74) 07-02 15:40:41.945: W/System.err(6711): at java.lang.Thread.run(Thread.java:841) 07-02 15:40:41.945: W/System.err(6711): Caused by: libcore.io.ErrnoException: connect failed: ECONNREFUSED (Connection refused) 07-02 15:40:41.945: W/System.err(6711): at libcore.io.Posix.connect(Native Method) 07-02 15:40:41.945: W/System.err(6711): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85) 07-02 15:40:41.945: W/System.err(6711): at libcore.io.IoBridge.connectErrno(IoBridge.java:127) 07-02 15:40:41.945: W/System.err(6711): at libcore.io.IoBridge.connect(IoBridge.java:112) 07-02 15:40:41.945: W/System.err(6711): ... 8 more 07-02 15:40:41.945: W/Sender(6711): failed to connect to /120.26.196.74 (port 10000): connect failed: ECONNREFUSED (Connection refused) 07-02 15:40:43.935: W/GatewayComponent(6711): mLogAction = LOGIN, failure: code = -2004, message = 發送消息沒有回執確認 07-02 15:40:43.935: D/GatewayService(6711): mPushLog.onFailed: code = -2004, message = 發送消息沒有回執確認
網上大部分人都說是因為同一個頁面(Activity),不同的View使用了相同的ID,導致在恢復時,findViewById,強制轉換SaveState類型錯誤,可是我對比了半天整個工程中就一個SlidingTabLayout(繼承HorizontalScrollView)使用了android:id="@+id/slidingTabLayout",應該不是網友說的這種情況,但是我也不知道為什么傳的AbsSavedState$1給HorizontalScrollView,無奈去翻源碼:
@Override protected void onRestoreInstanceState(Parcelable state) { if (mContext.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR2) { // Some old apps reused IDs in ways they shouldn't have. // Don't break them, but they don't get scroll state restoration. super.onRestoreInstanceState(state); return; } SavedState ss = (SavedState) state; super.onRestoreInstanceState(ss.getSuperState()); mSavedState = ss; requestLayout(); }
大概意思就是在Android API 18(4.2.2和4.4.2之間的一個版本)以前,不會保存ScrollView的滾動條位置,這個對我影響也不是很大,規避這個問題我能想到有如下兩種:
將AndroidMainifest.xml中android:targetSdkVersion降為18以下(如果需要記錄這個狀態,可以在onSaveInstanceState中記錄位置,onRestoreInstanceState中恢復就可以了);
不讓View保存狀態:
android:saveEnabled="false"|setSaveEnabled(false)|不要給view設置id
/** * Called by {@link #saveHierarchyState(android.util.SparseArray)} to store the state for * this view and its children. May be overridden to modify how freezing happens to a * view's children; for example, some views may want to not store state for their children. * * @param container The SparseArray in which to save the view's state. * * @see #dispatchRestoreInstanceState(android.util.SparseArray) * @see #saveHierarchyState(android.util.SparseArray) * @see #onSaveInstanceState() */ protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) { if (mID != NO_ID && (mViewFlags & SAVE_DISABLED_MASK) == 0) { mPrivateFlags &= ~PFLAG_SAVE_STATE_CALLED; Parcelable state = onSaveInstanceState(); if ((mPrivateFlags & PFLAG_SAVE_STATE_CALLED) == 0) { throw new IllegalStateException( "Derived class did not call super.onSaveInstanceState()"); } if (state != null) { // Log.i("View", "Freezing #" + Integer.toHexString(mID) // + ": " + state); container.put(mID, state); } } }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。