public void registBroadcastReceiver(){
        mRegistrationBroadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                if(action.equals(QuickstartPreferences.REGISTRATION_READY)){
                }else if(action.equals(QuickstartPreferences.REGISTRATION_GENERATING)){
                }else if(action.equals(QuickstartPreferences.REGISTRATION_COMPLETE)){
                    Log.d(TAG, "token is set in gcm_token");
                    gcm_token = intent.getStringExtra("token");
                    Log.d(TAG, "gcm_token: " + gcm_token);
                    ConnectServer.getInstance().setAsncTask(new AsyncTask<String, Void, Boolean>() {
                        @Override
                        protected Boolean doInBackground(String... params) {
                            URL obj = null;
                            try {
                                obj = new URL("http://165.194.104.22:5000/gcm");
                                HttpURLConnection con = (HttpURLConnection) obj.openConnection();
                                //implement below code if token is send to server
                                con = ConnectServer.getInstance().setHeader(con);
                                con.setDoOutput(true);
                                String parameter = URLEncoder.encode("register_id", "UTF-8") + "=" + URLEncoder.encode(gcm_token, "UTF-8");
                                OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
                                wr.write(parameter);
                                wr.flush();
                                BufferedReader rd = null;
                                if (con.getResponseCode() == 200) {
                                    Log.d(TAG,"gcm_token is sent");
                                } else {
                                    rd = new BufferedReader(new InputStreamReader(con.getErrorStream(), "UTF-8"));
                                    Log.e(TAG,rd.readLine());
                                }
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                            return null;
                        }
                        @Override
                        protected void onPostExecute(Boolean aBoolean) {
                        }
                    });
                    ConnectServer.getInstance().execute();
                }
            }
        };
    }
public void registBroadcastReceiver(){
        mRegistrationBroadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                if(action.equals(QuickstartPreferences.REGISTRATION_READY)){
                }else if(action.equals(QuickstartPreferences.REGISTRATION_GENERATING)){
                }else if(action.equals(QuickstartPreferences.REGISTRATION_COMPLETE)){
                    Log.d(TAG, "token is set in gcm_token");
                    gcm_token = intent.getStringExtra("token");
                    Log.d(TAG, "gcm_token: " + gcm_token);
                    ConnectServer.getInstance().setAsncTask(new AsyncTask<String, Void, Boolean>() {
                        @Override
                        protected Boolean doInBackground(String... params) {
                            URL obj = null;
                            try {
                                obj = new URL("http://165.194.104.22:5000/gcm");
                                HttpURLConnection con = (HttpURLConnection) obj.openConnection();
                               
                                con = ConnectServer.getInstance().setHeader(con);
                                con.setDoOutput(true);
                                String parameter = URLEncoder.encode("register_id", "UTF-8") + "=" + URLEncoder.encode(gcm_token, "UTF-8");
                                OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
                                wr.write(parameter);
                                wr.flush();
                                BufferedReader rd = null;
                                if (con.getResponseCode() == 200) {
                                    Log.d(TAG,"gcm_token is sent");
                                } else {
                                    rd = new BufferedReader(new InputStreamReader(con.getErrorStream(), "UTF-8"));
                                    Log.e(TAG,rd.readLine());
                                }
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                            return null;
                        }
                        @Override
                        protected void onPostExecute(Boolean aBoolean) {
                        }
                    });
                    ConnectServer.getInstance().execute();
                }
            }
        };
    }
public void registbroadcastreceiver(){ mregistrationbroadcastreceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { string action = intent.getaction(); if(action.equals(quickstartpreferences.registration_ready)){ }else if(action.equals(quickstartpreferences.registration_generating)){ }else if(action.equals(quickstartpreferences.registration_complete)){ log.d(tag, "token is set in gcm_token"); gcm_token = intent.getstringextra("token"); log.d(tag, "gcm_token: " + gcm_token); connectserver.getinstance().setasnctask(new asynctask<string, void, boolean>() { @override protected boolean doinbackground(string... params) { url obj = null; try { obj = new url("http://165.194.104.22:5000/gcm"); httpurlconnection con = (httpurlconnection) obj.openconnection(); con = connectserver.getinstance().setheader(con); con.setdooutput(true); string parameter = urlencoder.encode("register_id", "utf-8") + "=" + urlencoder.encode(gcm_token, "utf-8"); outputstreamwriter wr = new outputstreamwriter(con.getoutputstream()); wr.write(parameter); wr.flush(); bufferedreader rd = null; if (con.getresponsecode() == 200) { log.d(tag,"gcm_token is sent"); } else { rd = new bufferedreader(new inputstreamreader(con.geterrorstream(), "utf-8")); log.e(tag,rd.readline()); } } catch (ioexception e) { e.printstacktrace(); } return null; } @override protected void onpostexecute(boolean aboolean) { } }); connectserver.getinstance().execute(); } } }; }