android - okhttp3 - how to control network usage (upload throttling) -


i trying upload image using okhttp3 library.

what happens that, when upload starts, okhttp takes available bandwidth making impossible make other connection app or other app.

my code is:

progressrequestbody filebody = new progressrequestbody(     requestbody.create(mediatype.parse(getmimetype(sourcefile)), sourcefile),      new progressrequestbody.listener() {         @override         public void onprogress(int progress) {             //update progress         }     });  requestbody requestbody = new multipartbody.builder()     .settype(multipartbody.form)     .addformdatapart("key", key)     .addformdatapart("file", sourcefile.getname(), filebody)     .build();  request request = new request.builder()     .url(global.server_url + "upload")     .addheader("authorization", global.g_userinfo.getsessionid())     .post(requestbody)     .build();  response response = okhttpclient.newcall(request).execute(); responsestring = response.body().string(); statuscode = response.code(); 

implementation of countingrequestbody


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -