0

GCM を使用して登録 ID を生成していますが、罰金の値を生成しています。しかし、私の問題は、石鹸を使用してasp.netサーバーにデータを送信していることです。データベースに空の値を格納しています。
私はたくさん試しましたが、何が問題なのかわかりません。また、regIDの固定値を指定して確認し、その時点でデータを保存しました。
私のコードは次のとおりです。解決策を教えてください。

 private class TheTask extends AsyncTask<String, String, String> {
    @Override
    protected void onPreExecute() {

    }

    @Override
    protected String doInBackground(String... params) {

        GCMRegistrar.checkDevice(getApplicationContext());
        GCMRegistrar.checkManifest(getApplicationContext());

        String regId = GCMRegistrar
                .getRegistrationId(getApplicationContext());

        if (regId.equals("")) {
            flag = 1;
            GCMRegistrar.register(getApplicationContext(), "1507652xxxxx");

        } else {
            Log.v("Registration", "Already registered, regId: " + regId);
        }

        if (flag == 1) {
            regId = GCMRegistrar.getRegistrationId(getApplicationContext());

            request = new SoapObject(NAMESPACE, METHOD_NAME);

            regisid = new PropertyInfo();
            regisid.setName("RegId");
            regisid.setValue(regId);
            regisid.setType(String.class);
            request.addProperty(regisid);

            SoapSerializationEnvelope envp = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envp.dotNet = true;
            envp.setOutputSoapObject(request);
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            try {
                androidHttpTransport.call(SOAP_ACTION, envp);
                SoapPrimitive response = (SoapPrimitive) envp.getResponse();
                Response = response.toString();

            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        return Response;
    }

    @Override
    protected void onPostExecute(String result) {

    }
}
4

1 に答える 1

1

GCMIntentService の onRegistered コールバック メソッドで Web サービス呼び出しを行う必要があります。

public class GCMIntentService extends GCMBaseIntentService {

public GCMIntentService() {
    super(SENDER_ID);
}   


@Override
protected void onRegistered(Context arg0, String regId) {
    //Call webservice here

}
于 2013-06-06T05:51:28.077 に答える