0

これが私のコードです:

// begin the registration process
    status.setText("Registering...");
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("register.php");
    SharedPreferences settings = getSharedPreferences("settings", 0);
    String name = settings.getString("name", "");
    String email = settings.getString("email", "");
    String password = settings.getString("password", "");

    //get C2DM registration ID
    Context context = getApplicationContext();
    C2DMessaging.register(context, "qasim1iqbal");
    String reg_id = C2DMessaging.getRegistrationId(context);

    String HTML = "";
    try {
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("name", name));
        nameValuePairs.add(new BasicNameValuePair("email", email));
        nameValuePairs.add(new BasicNameValuePair("password", password));
        nameValuePairs.add(new BasicNameValuePair("reg_id", reg_id));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse response = httpclient.execute(httppost);
        HTML = EntityUtils.toString(response.getEntity());
        Toast msg = Toast.makeText(getApplicationContext(), HTML, Toast.LENGTH_LONG);
        msg.show();

        Intent i = new Intent(getBaseContext(), doneRegisterActivity.class);
        startActivityForResult(i, 0);
    } catch (ClientProtocolException e) {
    } catch (IOException e) {
    }

登録時にSERVICE_NOT_AVAILABLEエラーが発生しますが、これは何が原因でしょうか?これはアクティビティです。

4

1 に答える 1

2

C2DMページから:

デバイスが応答を読み取れないか、サーバーから500/503があり、後で再試行できます。アプリケーションは指数バックオフを使用して再試行する必要があります。

おそらくサーバーの一時的な中断。(つまり、それがあなたの側にあるのか疑わしい)。念のため、そのページにリストされているサンプルアプリのいずれかでクレデンシャルを使用してみて、そこで機能するかどうかを確認してください。

于 2011-08-09T00:48:08.903 に答える