Code example for GoogleCloudMessaging

Methods: register

0
            } 
        }.execute(null, null, null);
    } 
 
    public void onClick(final View view) {
        if (view == findViewById(R.id.send)) {
            new AsyncTask<Void, Void, String>() {
                @Override 
                protected String doInBackground(Void... params) {
                    String msg = "";
                    try { 
                        Bundle data = new Bundle();
                        data.putString("hello", "World");
                        String id = Integer.toString(msgId.incrementAndGet());
                        gcm.send(SENDER_ID + "@gcm.googleapis.com", id, data);
                        msg = "Sent message";
                    } catch (IOException ex) {
                        msg = "Error :" + ex.getMessage();
                    } 
                    return msg;
                }