[Android Exception 1 A]-com.android.volley.noconnectionerror:java.io.interruptedioexception

Source: Internet
Author: User

 A- -  -: +:47.470 24220-24220/com.tongyan.tutelage w/System.err:com.android.volley.NoConnectionError:java.io.InterruptedIOException A- -  -: +:47.470 24220-24220/com.tongyan.tutelage w/system.err:at com.android.volley.toolbox.BasicNetwork.performRequest (Basicnetwork.java: the) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage w/system.err:at Com.android.volley.NetworkDispatcher.run (Networkdispatcher.java: the) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage w/System.err:Caused by:java.io.InterruptedIOException A- -  -: +:47.470 24220-24220/com.tongyan.tutelage w/system.err:at com.android.okio.Deadline.throwIfReached (Deadline.java: About) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage W/system.err:at com.android.okio.okio$1. Write (Okio.java: the) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage w/system.err:at Com.android.okio.RealBufferedSink.flush (Realbufferedsink.java:154) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage W/system.err:at com.android.okhttp.Internal. http. Httpconnection.flush (Httpconnection.java: the) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage W/system.err:at com.android.okhttp.Internal. http. Httptransport.flushrequest (Httptransport.java: the) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage W/system.err:at com.android.okhttp.Internal. http. Httpengine.readresponse (Httpengine.java:626) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage W/system.err:at com.android.okhttp.Internal. http. Httpurlconnectionimpl.execute (Httpurlconnectionimpl.java:388) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage W/system.err:at com.android.okhttp.Internal. http. Httpurlconnectionimpl.getresponse (Httpurlconnectionimpl.java:332) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage W/system.err:at com.android.okhttp.Internal. http. Httpurlconnectionimpl.getresponsecode (Httpurlconnectionimpl.java: -) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage w/system.err:at com.android.volley.toolbox.HurlStack.performRequest (Hurlstack.java:109) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage w/system.err:at com.android.volley.toolbox.BasicNetwork.performRequest (Basicnetwork.java: the) A- -  -: +:47.470 24220-24220/com.tongyan.tutelage W/system.err: ...1More

This error is caused by your inadvertently, or is not very good to be familiar with the volley package API.

 Public voidonrequest (String url) {if(isintnetconn) {stringrequest request=NewStringrequest (URL,NewResponse.listener<string>() {@Override Public voidOnresponse (String s) {mlistener.onsuccess (s); }            }, NewResponse.errorlistener () {@Override Public voidonerrorresponse (Volleyerror volleyerror) {String errormsg=""; if(volleyerror instanceof timeouterror) {mlistener.onerror (); } Else if(volleyerror instanceof servererror) {mlistener.onerror (); } Else{mlistener.onerror (); ErrorMsg= Mcontext.getresources (). getString (R.string. Request_error);            }                }            }); Request.setretrypolicy (NewDefaultretrypolicy ( -* +,0,1.0f));//setting the time-out periodMqueue.add (Request); //Mqueue.start ();}Else{toast.maketext (Mcontext,"The current network connection is not available", Toast.length_short). Show ();        Mlistener.onintnetdisconn (); }    }

Just add the following sentence, the bug as scheduled.

// Mqueue.start ();

In fact, when the Requestqueue instantiation, there is already a start.

Private requestqueue Mqueue; Private Context Mcontext;  Public httpserviceutils (Httpresquestlistener listener,context Context) {       = listener;        = context;       Mqueue  = volley.newrequestqueue (context);}
 Public classVolley {Private StaticFinal String Default_cache_dir ="Volley";  Publicvolley () {} Public StaticRequestqueue Newrequestqueue (context context, Httpstack stack) {File Cachedir=NewFile (Context.getcachedir (),"Volley"); String useragent="volley/0"; Try{String Network=Context.getpackagename (); PackageInfo Queue= Context.getpackagemanager (). Getpackageinfo (Network,0); UserAgent= Network +"/"+Queue.versioncode; } Catch(Namenotfoundexception var6) {; }        if(Stack = =NULL) {            if(VERSION. Sdk_int >=9) {Stack=NewHurlstack (); } Else{Stack=NewHttpclientstack (Androidhttpclient.newinstance (useragent)); }} basicnetwork Network1=Newbasicnetwork ((httpstack) stack); Requestqueue queue1=NewRequestqueue (NewDiskbasedcache (Cachedir), NETWORK1);        Queue1.start (); returnqueue1; }     Public StaticRequestqueue Newrequestqueue (context context) {returnNewrequestqueue (context, (Httpstack)NULL); }}

Queue1.start (); It was called when the Requestqueue was instantiated.

https://stackoverflow.com/questions/31158858/ random-com-android-volley-noconnection-error-java-io-interruptedioexception-st/31181611#31181611

[Android Exception 1 A]-com.android.volley.noconnectionerror:java.io.interruptedioexception

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.