Fun with AndroidHttpClient (Java.Lang.Runtime exception)

Chris.3704Chris.3704 USUniversity ✭✭

Hi,

I'm trying to implement a simple Http Get Request with AndroidHttpClient (yes, I have to use AndroidHttpClient). Apparently, things aren't that easy.
I'm failing on this line (see below):
while ((line = reader.ReadLine()) != null)
with a Java.Lang.Runtime exception.

Does anyone have an idea what I might be doing wrong?

Thanks!

                using (var client = AndroidHttpClient.NewInstance("AppConnectClient"))
                {

                    try {
                        // Create Request
                        HttpGet get = new HttpGet(url);
                        var responseTask = client.ExecuteAsync(get);
                        var response = await responseTask;
                        var entity = response.Entity;
                        var resultBuilder = new StringBuilder();

                    using (var reader = new BufferedReader(new InputStreamReader(entity.Content)))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            resultBuilder.AppendLine(line);
                        }
                    }
                    client.Close();
                }
                catch(Exception ex) {
                    // Print exception          
                }

Answers

Sign In or Register to comment.