0
지금 인터넷을 해봤는데 등록 ID와 장치 ID를 서버에 보내려면 Android 앱을 가져올 수 없습니다. 내가 누락 된 단순한 무언가가있을 것이라고 확신하지만, 내가 잘못한 것을 누구라도 볼 수 있습니까? 코드가 맞고 토스트가 표시되지만 서버가 아무 것도하지 않지만 URL에 직접 가면 원하는대로 처리합니다.C2DM 등록 ID를 서버에 보내는 방법
if (!regId.equals("")) {
Toast.makeText(context, "The registration ID is: " + regId,
Toast.LENGTH_LONG).show();
Toast.makeText(context, "The device ID is: " + deviceId,
Toast.LENGTH_LONG).show();
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://uni.britintel.co.uk/register.php");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("deviceId", deviceId));
nameValuePairs.add(new BasicNameValuePair("registrationId", regId));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse httpresponse = httpclient.execute(httppost);
BufferedReader rd = new BufferedReader(new InputStreamReader(
httpresponse.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
Log.e("HttpResponse", line);
Toast.makeText(context, line,
Toast.LENGTH_LONG).show();
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
} else {
Toast.makeText(context, "The registration ID doesn't exist",
Toast.LENGTH_LONG).show();
}
버퍼링 된 리더는 일단 내가 원하는대로 무의미 해지면 제거됩니다.
도움을 주셔서 감사합니다.
POST 대신 GET을 사용하려고했지만 여전히 작동하지 않습니다. – gigaSproule