- Home /
 
               Question by 
               nokto · Jul 18, 2016 at 04:10 PM · 
                androidassetbundleshttpwebrequest  
              
 
              HttpWebRequest Async not working on Android
The following simple code wants to download an asset bundle asynchronously from a given URL:
         private void GetWebContent(String _url) {
             Debug.Log("Creating webrequest with URL = " + _url);
             _request = WebRequest.Create(_url);
             IAsyncResult responseAsyncResult = _request.BeginGetResponse(ResponseCallbackWebRequest, null);
         }
 
         private void ResponseCallbackWebRequest(IAsyncResult state) {
             Debug.Log("ResponseCallbackWebRequest webrequest with URL = " + _url + "\nstate = " + state.ToString()); // This is the last print that I get in Android
 
             WebResponse response = _request.EndGetResponse(state);
             Debug.Log("A"); // this line is never printed out
             long contentLength = response.ContentLength;
             if (contentLength == -1) {
                 _error = "Could not get a response from " + url;
                 Debug.Log(_error);
             } else {
                 Debug.Log("Content Length is " + contentLength);
             }
 
             //... extra stuff here
         }
 
I tried both my real asset bundle URL and something fake like 'http://www.google.com' and the result is pretty strange: the code behaves as expected under my Mac and silently fails under Android (no crashes, and the last line printed is the first Log from ResponseCallbackWebRequest).
Is there anything terribly obvious that I'm missing?
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
AssetBundle instantiation in android/ios 0 Answers
Max Size of Textures from AssetBundle 1 Answer
HTTP Requests removed on Android Pie (API 28+) 2 Answers
HttpWebRequest to https on Android? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                