Hi, I am trying to implement c2dm and saving the ids into my server.
However when im trying to connect/save values to the server, There's
always an error showing that the target server failed to respond. What
could be the cause?
This is my code:
public void sendRegistrationIdToServer(String deviceId,
String registrationId) {
Log.d("C2DM", "Sending registration ID to my application
server");
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://172.28.28.28/test.php?");
try {
List<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>(1);
// Get the deviceID
nameValuePairs.add(new BasicNameValuePair("deviceid",
deviceId));
nameValuePairs.add(new
BasicNameValuePair("registrationid",
registrationId));
try {
post.setEntity(new
UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Log.i("LEE", "cannot connect to server");
}
// Execute HTTP Post Request
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new
InputStreamReader(
response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
Log.e("HttpResponse", line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en