0
Explanation:
I own a simple Android app, and also a Nodejs server. I have the following permissions on AndroidManifest.xml
of my application:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
I am trying to perform an HTTP Post and a Local URL, but this generates an unknown error:null
, when running HTTP Post. So I have no way of knowing what’s going on.
I’ve checked Logcat but no mistakes, just that mistake null
of my Exception is appearing.
Here is the HTTP Post code:
HttpPost post = new HttpPost("http://192.168.25.32:8080/signup");
HttpParams params = new BasicHttpParams(); //eu estava usando Params, agora uso Pairs
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("name", "Teste2"));
pairs.add(new BasicNameValuePair("email", "[email protected]"));
pairs.add(new BasicNameValuePair("country", "Brazil"));
pairs.add(new BasicNameValuePair("user", "teste"));
pairs.add(new BasicNameValuePair("pass", "123456"));
post.setEntity(new UrlEncodedFormEntity(pairs));
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(post); //aqui vai para a Exception
Question:
What am I doing wrong? How can I solve this problem ?
I would also like to know why this error is being generated.
Observing:
When accessing http://192.168.25.32:8080/signup
I have an html registration form working right, from there to know that my Nodejs server is communicating right, and working, so I’m sure the error is on Android.
Try to stop using IP to use a URL
– Gabriel Augusto
Impossible. It is a local network address.
– Paulo Roberto Rosa