1) You should be creating the PushRegistrar object in a static block in your activity OR in the onCreate method of your Application (also make sure you have subclassed application and set that class to the name property of your application in your AndroidManifest.)

2) You need to also make sure that register() is called before unregister().  If Android kills your application you will need to call register to call unregister.  It is a bit counter intuitive but it keeps your registration state in sync with GCM so that you are properly unregistered.

3) Do you have a github we can take a look at with the project in it?  

On Fri, Jul 17, 2015 at 12:56 PM, alan10fm <alan10fm@gmail.com> wrote:
Hi everybody.

I am making an android app using unified push server and Openshift.
I am using the code in the next link to register my devices
https://aerogear.org/docs/guides/aerogear-android/push/
the register works good and i can receive push notification.
My problem is when i want to unregister the device, when i register the
device and i never close the app and i unregister the device it works but my
issue is when i register my device and close the app, after relaunch the app
when i try to unregister the device the app brokes because of a null pointer
exception in this line
registrar.unregister(getApplicationContext(), new Callback<Void>()
because the registar object is null

I have made a lot of combinations to recover the registar object but
anything works the server returns me a 404 code error.
In this link is my code:
https://stackoverflow.com/questions/31363464/unregister-devices-aerogear

I will appreciate any help with this.
--




--
View this message in context: http://aerogear-users.1116366.n5.nabble.com/Issues-unregistering-from-server-tp140.html
Sent from the aerogear-users mailing list archive at Nabble.com.
_______________________________________________
Aerogear-users mailing list
Aerogear-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-users