View onrestoreinstancestate classcastexception

Source: Internet
Author: User

Encountered a difficult problem, search for n days of no solution:

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_scode07-02 15:40:29.105: d/gatewaypresentor (6711):  logout: component =  push07-02 15:40:29.105: d/gatewaycomponent (6711):  logout07-02 15:40:29.105: w/ Gatewaycomponent (6711):  mlogged = false, msender = [email protected]07-02  15:40:29.105: d/workorderfragment (6711):  ondetach07-02 15:40:29.105: d/orderfragment (6711):  ondetach07-02 15:40:29.115: d/gatewaypresentor (6711):  login: component = push, accesskey = 2 , userid = 2, token = 5ad04ba7-de02-4203-a077-a79581c8925207-02  15:40:29.115: d/gatewaycomponent (6711):  login: accesskey = 2, userid =  2, token = 5ad04ba7-de02-4203-a077-a79581c8925207-02 15:40:29.115: i/sender ( 6711):  generated message number: 616681209340520038707-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 =null07-02 15:40:29.125: d/orderfragment (6711): onattach07-02  15:40:29.155: d/androidruntime (6711):  sHUTTING&NBSP;DOWN&NBSP;VM07-02&NBSP;15:40:29.155:&NBSP;W/DALVIKVM (6711): threadid=1: thread  exiting with uncaught exception  (group=0x4173cd58) 07-02 15:40:29.155: e/ Androidruntime (6711):  fatal exception: main07-02 15:40:29.155: e/androidruntime (6711) :  process: com.autonavi.taoparking.parker, pid: 671107-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$savedstate07-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): &NBSp;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$savedstate07-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 more07-02  15:40:31.695: i/sender (6711): &nbsp, ....... Send Heartbeat 07-02 15:40:31.825: i/sender (6711):  retry connection to server 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 more07-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):  .............. Send Heartbeat 07-02 15:40:41.885: i/sender (6711):  retry the connection to the server 07-02 15:40:41.945: w/ Gatewaycomponent (6711): mlogaction = login, failure: code = -2004,  message =  Send Message no acknowledgement 07-02 15:40:41.945: d/gatewayservice (6711):  mlocationlog.onfailed : &NBSP;CODE&NBSP;=&NBsp;-2004, message =  Send Message no acknowledgement 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&Nbsp;more07-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 =  Send message no acknowledgement of receipt 07-02 15:40:43.935: d/ Gatewayservice (6711): mpushlog.onfailed: code = -2004, message =  Send message no acknowledgement of receipt


Most people on the web say that because of the same page (Activity), different view uses the same ID, resulting in Findviewbyid, cast savestate type error when recovering, But I compared to a half-day project in a Slidingtablayout (inherited Horizontalscrollview) use of android:id= "@+id/slidingtablayout", should not be a netizen said hungry this situation, Helpless to turn the source of 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 ();     }

Probably means that in the Android API 18 (4.2.2 and 4.4.2 a version between), will not save the ScrollView scroll bar position, this impact on me is not very big, to circumvent this problem I can think of the following two kinds:

    1. Reduce the android:targetsdkversion in Androidmainifest.xml to 18 (if you need to record this status, you can record the position in the onsaveinstancestate, Onrestoreinstancestate recovery is possible);

    2. Try catch processing, although not solved fundamentally, but avoids the program crash;

@Overrideprotected void Onrestoreinstancestate (parcelable state) {LOGUTIL.D (Log_tag, "onrestoreinstancestate:state = ' + state '; try {super.onrestoreinstancestate (state);} catch (ClassCastException e) {e.printstacktrace ();}}


This article is from the "Beyond the Dream" blog, please be sure to keep this source http://lbrant.blog.51cto.com/2400264/1670280

View onrestoreinstancestate classcastexception

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.