Back to project page hpush.
The source code is released under:
MIT License
If you think the Android project hpush listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.hpush.gcm; // w ww . j av a2 s . c om import java.io.IOException; import android.content.Context; import android.os.AsyncTask; import com.google.android.gms.gcm.GoogleCloudMessaging; import com.hpush.bus.DeleteAccountEvent; import com.hpush.utils.Prefs; import de.greenrobot.event.EventBus; /** * Register GCM. * * @author Xinyue Zhao */ public class UnregGCMTask extends AsyncTask<Void, Void, String> { private GoogleCloudMessaging mGCM; private Prefs mPrefs; public UnregGCMTask(Context context ) { mGCM = GoogleCloudMessaging.getInstance(context); mPrefs = Prefs.getInstance(context.getApplicationContext()); } @Override protected String doInBackground(Void... params) { String regId; try { mGCM.unregister(); regId = mPrefs.getPushRegId(); mPrefs.turnOffPush(); } catch (IOException ex) { regId = null; } return regId; } @Override protected void onPostExecute(final String regId) { // if (!TextUtils.isEmpty(regId)) { mPrefs.setPushRegId(null); EventBus.getDefault().postSticky(new DeleteAccountEvent()); // } } }