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