I'm trying to put a get/post request on link http://103.48.108.35:5005/dataitsno but no request is pinging on my server I'm using following code on my android application. I also want to send it in background request(does not hamper current process).
public void SendCont() throws UnsupportedEncodingException {
String Name="Raj";
String OwnNo="85859657";
String text="";
String data = URLEncoder.encode("owndat","UTF-8")+"="+URLEncoder.encode(OwnNo, "UTF-8");
data += "&" + URLEncoder.encode("cont", "UTF-8") + "=" + URLEncoder.encode(Name, "UTF-8");
BufferedReader reader=null;
try
{
URL url = new URL("http://103.48.108.35:5005/dataitsno?quer='"+OwnNo+"'");
// Send POST data request
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write( data );
wr.flush();
// Get the server response
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line = null;
// Read Server Response
while((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
text = sb.toString();
}
catch(Exception ex)
{
}
finally
{
try
{
reader.close();
}
catch(Exception ex) {}
}
// Show response on activity
//content.setText( text );
}