Reputation: 69
I have the following simple HttpWebRequest in my code behind for click event: (VS 2017)
public void Button_Clicked(object sender, EventArgs e)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://192.168.0.10/api/c3knn1r79DQY391tANlYD9u9Jlm4U5Ch54lqm2fd/lights/6/state");
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "PUT";
request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request);
valueLabel.Text = "DONE";
}
public static void GetRequestStreamCallback(IAsyncResult asynchronousResult)
{
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
Stream postStream = request.EndGetRequestStream(asynchronousResult);
string postData = "{\"on\":true}";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
postStream.Write(byteArray, 0, postData.Length);
request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
}
public static void GetResponseCallback(IAsyncResult asynchronousResult)
{
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
Stream streamResponse = response.GetResponseStream();
StreamReader streamRead = new StreamReader(streamResponse);
string responseString = streamRead.ReadToEnd();
}
And it seems to work in my visualstudio_andriod-23_x86. and it turn the light on. BUT when I deploy that to my Samsung Note 4 device, nothing is happening. NO error or nothing and no lights comes on. I add premission to INTERNET under Android Manifest. here is the out put log:
Also, I noticed in the log that: AOT module 'System.Net.Requests.dll.so' not found: dlopen failed: library "/data/app/App2.Android-1/lib/arm/libaot-System.Net.Requests.dll.so" not found
But I get this Error line in working Emulator. so that is not the issue. Any ideas any one? Please help. Thanks
Upvotes: 0
Views: 78
Reputation: 69
Well, after spending hours I realized that I had to reset the router. And it is working now
Upvotes: 1