-4
private void registerBackground(){

           Log.v(TAG,"-----regbackgroud method call---");

     new AsyncTask<Void, Void, String>() {


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

              String msg = "";

                try {
                    if (gcm == null) {
                        gcm = GoogleCloudMessaging.getInstance(context);
                  }
                    regid = gcm.register(SENDER_ID);

                    msg = "Device registered, registration id=" + regid;


                    setRegistrationId(context, regid);


                } catch (IOException ex) {
                    msg = "Error ::" + ex.getMessage();

                }
                return msg;

            }


          @Override
          protected void onPostExecute(String msg) {
              super.onPostExecute(msg);

          }

          @Override
          protected void onPreExecute() {
              super.onPreExecute();

          }
      }.execute(null, null, null);

}

Here My My code In this
1) Preexecuted Method Executed And
2) doInbackground() method does not executed.
please suggest me what should i have to do and Any Error Occure When JNI Is On ...

Bhavin Nattar
  • 3,189
  • 2
  • 22
  • 30

1 Answers1

2

No need to call in background

Try Call this method

public void enableGCM() {

        try {
            GCMRegistrar.checkDevice(this);
            GCMRegistrar.checkManifest(this);
            final String regId = GCMRegistrar.getRegistrationId(this);
            if (regId.equals("")) {
                GCMRegistrar.register(this, SENDER_ID);
            } else {
                Log.v("GCM", "Already registered");
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77