Click here to Skip to main content
15,901,284 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Java
protected void onCreate(Bundle savedInstanceState) {
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
            String IMEI="1234566";
            String Phonemodel="Samsung";
            HttpClient httpClient=new DefaultHttpClient();
//        HttpPost httpPost=new HttpPost("http://localhost:50554/api/vetri?id="+Id+"&Imei="+Imei+"Btrylevel="+Battery);
            HttpPost httpPost1=new HttpPost("http://kredo.no-ip.org/SSMA/api/DevicesAPI/RegisterDevice?IMEI="+IMEI+"&Phonemodel="+Phonemodel);
            try {
                HttpResponse response=httpClient.execute(httpPost1);
            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
      }
Posted
Updated 5-May-15 23:59pm
v2
Comments
[no name] 6-May-15 6:00am    
Do u got any error?
Member 11420908 6-May-15 6:07am    
No
OriginalGriff 6-May-15 6:05am    
How would we know?
We have do idea what you expect it to do!
Member 11420908 6-May-15 6:07am    
i want post values to the url
CHill60 6-May-15 6:08am    
So what happens when you run it???

1 solution

Hello,

I recommend to check the server status. Your error is empty but there is respone from server. How to get it?

Add this line please:

HttpResponse responseFromServer = httpClient.execute(postMethod);
int status = responseFromServer.getStatusLine().getStatusCode();


Check the status variable.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900