diff --git a/android-gcm-client/AndroidManifest.xml b/android-gcm-client/AndroidManifest.xml
new file mode 100644
index 0000000..2cd7401
--- /dev/null
+++ b/android-gcm-client/AndroidManifest.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-gcm-client/res/drawable-hdpi/ic_launcher.png b/android-gcm-client/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..288b665
Binary files /dev/null and b/android-gcm-client/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android-gcm-client/res/layout/activity_main.xml b/android-gcm-client/res/layout/activity_main.xml
new file mode 100644
index 0000000..07bda30
--- /dev/null
+++ b/android-gcm-client/res/layout/activity_main.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
diff --git a/android-gcm-client/res/menu/main.xml b/android-gcm-client/res/menu/main.xml
new file mode 100644
index 0000000..c002028
--- /dev/null
+++ b/android-gcm-client/res/menu/main.xml
@@ -0,0 +1,9 @@
+
diff --git a/android-gcm-client/res/values/dimens.xml b/android-gcm-client/res/values/dimens.xml
new file mode 100644
index 0000000..55c1e59
--- /dev/null
+++ b/android-gcm-client/res/values/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/android-gcm-client/res/values/strings.xml b/android-gcm-client/res/values/strings.xml
new file mode 100644
index 0000000..8d9b6bd
--- /dev/null
+++ b/android-gcm-client/res/values/strings.xml
@@ -0,0 +1,8 @@
+
+
+
+ Android GCM
+ Settings
+ Hello world!
+
+
diff --git a/android-gcm-client/res/values/styles.xml b/android-gcm-client/res/values/styles.xml
new file mode 100644
index 0000000..6ce89c7
--- /dev/null
+++ b/android-gcm-client/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/android-gcm-client/src/com/hmkcode/android/gcm/GcmBroadcastReceiver.java b/android-gcm-client/src/com/hmkcode/android/gcm/GcmBroadcastReceiver.java
new file mode 100644
index 0000000..822e208
--- /dev/null
+++ b/android-gcm-client/src/com/hmkcode/android/gcm/GcmBroadcastReceiver.java
@@ -0,0 +1,23 @@
+package com.hmkcode.android.gcm;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.support.v4.content.WakefulBroadcastReceiver;
+
+public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
+
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+
+ // Explicitly specify that GcmMessageHandler will handle the intent.
+ ComponentName comp = new ComponentName(context.getPackageName(),
+ GcmMessageHandler.class.getName());
+
+ // Start the service, keeping the device awake while it is launching.
+ startWakefulService(context, (intent.setComponent(comp)));
+ setResultCode(Activity.RESULT_OK);
+ }
+}
diff --git a/android-gcm-client/src/com/hmkcode/android/gcm/GcmMessageHandler.java b/android-gcm-client/src/com/hmkcode/android/gcm/GcmMessageHandler.java
new file mode 100644
index 0000000..14714a8
--- /dev/null
+++ b/android-gcm-client/src/com/hmkcode/android/gcm/GcmMessageHandler.java
@@ -0,0 +1,56 @@
+package com.hmkcode.android.gcm;
+
+import com.google.android.gms.gcm.GoogleCloudMessaging;
+
+import android.app.IntentService;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+import android.widget.Toast;
+
+public class GcmMessageHandler extends IntentService {
+
+ String mes;
+ private Handler handler;
+ public GcmMessageHandler() {
+ super("GcmMessageHandler");
+ }
+
+ @Override
+ public void onCreate() {
+ // TODO Auto-generated method stub
+ super.onCreate();
+ handler = new Handler();
+ }
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ Bundle extras = intent.getExtras();
+
+ GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
+ // The getMessageType() intent parameter must be the intent you received
+ // in your BroadcastReceiver.
+ String messageType = gcm.getMessageType(intent);
+
+ mes = extras.getString("title");
+ showToast();
+ Log.i("GCM", "Received : (" +messageType+") "+extras.getString("title"));
+
+
+
+ GcmBroadcastReceiver.completeWakefulIntent(intent);
+
+ }
+
+ public void showToast(){
+ handler.post(new Runnable() {
+ public void run() {
+ Toast.makeText(getApplicationContext(),mes , Toast.LENGTH_LONG).show();
+ }
+ });
+
+ }
+
+
+
+}
diff --git a/android-gcm-client/src/com/hmkcode/android/gcm/MainActivity.java b/android-gcm-client/src/com/hmkcode/android/gcm/MainActivity.java
new file mode 100644
index 0000000..627d769
--- /dev/null
+++ b/android-gcm-client/src/com/hmkcode/android/gcm/MainActivity.java
@@ -0,0 +1,67 @@
+package com.hmkcode.android.gcm;
+
+import java.io.IOException;
+
+import com.google.android.gms.gcm.GoogleCloudMessaging;
+
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.app.Activity;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class MainActivity extends Activity implements OnClickListener {
+
+ Button btnRegId;
+ EditText etRegId;
+ GoogleCloudMessaging gcm;
+ String regid;
+ String PROJECT_NUMBER = "1024888653441";
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ btnRegId = (Button) findViewById(R.id.btnGetRegId);
+ etRegId = (EditText) findViewById(R.id.etRegId);
+
+ btnRegId.setOnClickListener(this);
+ }
+ public void getRegId(){
+ new AsyncTask() {
+ @Override
+ protected String doInBackground(Void... params) {
+ String msg = "";
+ try {
+ if (gcm == null) {
+ gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
+ }
+ regid = gcm.register(PROJECT_NUMBER);
+ msg = "Device registered, registration ID=" + regid;
+ Log.i("GCM", msg);
+
+
+ } catch (IOException ex) {
+ msg = "Error :" + ex.getMessage();
+
+ }
+ return msg;
+ }
+
+ @Override
+ protected void onPostExecute(String msg) {
+ etRegId.setText(msg + "\n");
+ }
+ }.execute(null, null, null);
+ }
+ @Override
+ public void onClick(View v) {
+ getRegId();
+ }
+
+}