Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • stop GCM notification

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 150
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: