0

This is really annoying me. I have an app that uses GCM and GCM works on all the device except SAMSUNG NEXUS 4. It always give me "SERVICE_NOT_AVAILABLE" error.

Following is the code snippet I have used for Registration.

private class GCMregisterAsyncTask extends AsyncTask<Void, Void, String> {

    @Override
    protected String doInBackground(Void... params) {
        String msg = "";
        int count = 0;
        do {
            try {
                if (gcm == null) {
                    gcm = GoogleCloudMessaging.getInstance(context);
                }

                regId = gcm.register(GOOGLE_PROJECT_ID);
                msg = "Device registered with GCM Server. Id= " + regId;
                storeRegistrationId(context, regId);
            } catch (IOException ex) {
                msg = "Error :" + ex.getMessage();
                this.cancel(true);
                this.execute();
            }
            count++;
            Logger.debug("count" + count);
        } while (count <= 3);
        return msg;
    }

    @Override
    protected void onPostExecute(String msg) {
        if (msg != null && !msg.contains("error")) {
            //Success
        }
    }
}

Thanx in advance.

akshay
  • 5,811
  • 5
  • 39
  • 58

0 Answers0