String apiKey = ""; //API key provided by Google Console String deviceID="";//Device Id Content content = new Content(); //POJO class as above for standard message format content.addRegId(deviceID); content.createData("Title", "Notification Message"); URL url = new URL("https://android.googleapis.com/gcm/send"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Authorization", "key="+apiKey); conn.setDoOutput(true); ObjectMapper mapper = new ObjectMapper(); DataOutputStream wr = new DataOutputStream(conn.getOutputStream()); mapper.writeValue(wr, content); wr.flush(); wr.close(); responseCode = conn.getResponseCode();