sometime its necessary to stop or unregister notification services in your app like from your setting screen then you can use these codes.
you have to create a static handler in your gcm register class
static Handler myHandler;
and in your particular activity'oncreate method
myHandler = new Handler()
{
public void handleMessage(android.os.Message sendMsg)
{
super.handleMessage(sendMsg);
if (sendMsg.what == 0)
{
GCMRegistrar.unregister(context);
}
}
};
now obtain message for this handler and tell your gcm register class that you want to stop that gcm service like this
Message msg=MainActivity.mHandler.obtainMessage();
msg.what=0;
MainActivity.mHandler.sendMessage(msg);
0 Comment(s)