Code example for GoogleCloudMessaging

Methods: register

0
			String msg = "";
	        try { 
	            if (gcm == null) {
	                gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
	            } 
	            regid = gcm.register(SENDER_ID);
	            msg = "Device registered, registration id=" + regid;
 
	            // You should send the registration ID to your server over HTTP, 
	            // so it can use GCM/HTTP or CCS to send messages to your app. 
 
	            // For this demo: we don't need to send it because the device 
	            // will send upstream messages to a server that echo back the message 
	            // using the 'from' address in the message. 
 
	            // Save the regid - no need to register again. 
	            try { 
	    	        // Add your data 
	            	List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
	                nameValuePairs.add(new BasicNameValuePair("regID", regid));