Google Cloud Messaging For Android (GCM) Simple Tutorial

Important: C2DM has been officially deprecated as of June 26, 2012.

It has been replaced by Google Cloud Messaging For Android (GCM)

This Tutorial will guide you how to create a sample simple application using the GCM functionality,

This demo will help you registering and unRegistering android device from GCM server

Getting your Sender ID

  • STEP 1.  Register Here .
  • STEP 2.  Click Create project. Your browser URL will change to something like:
    " https://code.google.com/apis/console/#project:4815162342 "

    Take note of the value after #project: (4815162342 in this example). This is your project ID, and it will be used later on as the GCM sender ID. This Id will be used by the Android Device while Registering for Push Notification.

  • STEP 3. Choose Service tab from the left side menu on the web page. and turn on " Google Cloud Messaging for Android "
  • STEP 4. Go to API Access tab from the left menu of web page.

press Create new Server key and note down the generated key

 

CREATING APP FOR GCM

  1. Update ADT plugin 20 .
  2. update SDK > install Extras > Google Cloud Messaging for Android Library.
  3. Add gcm.jar to libs folder.(will be in the  android_sdk/extras/google/gcm after updating ADT and SDK)
  • STEP 5. Create A new Project in Android with the following specifications

Android Version 2.2

Package   =  com.sagar.gcma

Main Activity  =  PushAndroidActivity

  • Source Code for PushAndroidActivity.java:
package com.sagar.gcma;

import static com.sagar.gcma.CommonUtilities.SENDER_ID;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.google.android.gcm.GCMRegistrar;

public class PushAndroidActivity extends Activity {

private String TAG = "** pushAndroidActivity **";
private TextView mDisplay;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

checkNotNull(SENDER_ID, "SENDER_ID");

GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);

setContentView(R.layout.main);
mDisplay = (TextView) findViewById(R.id.display);

final String regId = GCMRegistrar.getRegistrationId(this);
Log.i(TAG, "registration id =====  "+regId);

if (regId.equals("")) {
GCMRegistrar.register(this, SENDER_ID);
} else {
Log.v(TAG, "Already registered");
}

mDisplay.setText("ffffff        "+regId);
}

private void checkNotNull(Object reference, String name) {
if (reference == null) {
throw new NullPointerException(
getString(R.string.error_config, name));
}
}

@Override
protected void onPause() {
super.onPause();
GCMRegistrar.unregister(this);
}
}

 

  • Source code for GCMIntentService.java :
package com.sagar.gcma;

import static com.sagar.gcma.CommonUtilities.SENDER_ID;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.google.android.gcm.GCMBaseIntentService;

public class GCMIntentService extends GCMBaseIntentService{

public GCMIntentService() {
super(SENDER_ID);
}

private static final String TAG = "===GCMIntentService===";


@Override
protected void onRegistered(Context arg0, String registrationId) {
Log.i(TAG, "Device registered: regId = " + registrationId);
}

@Override
protected void onUnregistered(Context arg0, String arg1) {
Log.i(TAG, "unregistered = "+arg1);
}

@Override
protected void onMessage(Context arg0, Intent arg1) {
Log.i(TAG, "new message= ");
}

@Override
protected void onError(Context arg0, String errorId) {
Log.i(TAG, "Received error: " + errorId);
}

@Override
protected boolean onRecoverableError(Context context, String errorId) {
return super.onRecoverableError(context, errorId);
}
}


  • Source Code for CommonUtilities.java
package com.sagar.gcma;

public final class CommonUtilities {

static final String SENDER_ID = "515850168860";

}
  • Source Code for AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sagar.gcma"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />

<permission
android:name="com.sagar.gcma.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.sagar.gcma.permission.C2D_MESSAGE" />

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".PushAndroidActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />

<category android:name="com.sagar.gcma" />
</intent-filter>
</receiver>

<service android:name=".GCMIntentService" />
</application>

</manifest>

 

  • SourceCode of main.xml
</pre>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<TextView
android:id="@+id/display"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff" />

</ScrollView>
<pre>

Package explorer ScreenShot

Logcat ScreenShot

Important links:

About these ads

38 Responses

  1. there’s no doubt that your blog has the best explanation on this matter. thanks for all you’ve done.http://www.viagensdeturismo.org

  2. heya..thanks for the post and great tips…i think that hard work is the most important aspect of getting success.http://www.guiadenegocio.org

  3. newB here, but … line: in main.xml throws error.

  4. okay it deleted my tag … next to last line:

  5. disregard previous 2 posts … but:

    1) had to add: import com.sagar.gcma.R; to PushAndroidActivity.java
    2) had to add “error_config” element for “My config error text” to res\values\strings.xml

    even so still getting other errors …

  6. can you paste the error log here

  7. i understood the concept but…

    Can i know how to run this app on a mobile?
    Is it just launching it on the mobile?
    How does this app get connected so that any message pusehd on the server reaches the mobile?

  8. Hello Sharath
    Actually this code is just for getting the registration key.
    Once you get the registration key u can send it to your server and using that key your server will broadcast the message,

    And on your side the you will need a broadcast receiver that will handle that message.

  9. Hi,
    could you please post a sample code for server side (eg: java/jsp). Thanks

  10. thats great stuff but I need help with server side code :/ can I have its code ?

    • Hello Khurram,
      I am very thankful if you like this, Actually I am a little busy these days thats why could not update the server side code for this but I will do it surely but may take some time .

      thank you

  11. Need Help… I tried this but gives me log output as device has no accounts and asyncFetch: no username… I created new project and put my SENDER_ID…..

  12. excuse me sir , GCM example application..?

  13. hey plz update server side code using servlets or some other mechanism…

  14. hi,

    getting an error that “error_config cannot be resolved or is not a field”.
    Could you please resolve it.

    Thanks

  15. hi

    i have geeing an error “error_config cannot be resolved or is not a field”.
    Can you please help me to get over ride of it.

    thanks.

  16. Hi,
    here is my logcat details. Please do something.

    09-29 10:52:31.608: D/AndroidRuntime(277): Shutting down VM
    09-29 10:52:31.608: W/dalvikvm(277): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    09-29 10:52:31.778: E/AndroidRuntime(277): FATAL EXCEPTION: main
    09-29 10:52:31.778: E/AndroidRuntime(277): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.komal.gcma/com.komal.gcma.PushAndroidActivity}: java.lang.ClassNotFoundException: com.komal.gcma.PushAndroidActivity in loader dalvik.system.PathClassLoader[/data/app/com.komal.gcma-1.apk]
    09-29 10:52:31.778: E/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
    09-29 10:52:31.778: E/AndroidRuntime(277): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    09-29 10:52:31.778: E/AndroidRuntime(277): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    09-29 10:52:31.778: E/AndroidRuntime(277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    09-29 10:52:31.778: E/AndroidRuntime(277): at android.os.Handler.dispatchMessage(Handler.java:99)
    09-29 10:52:31.778: E/AndroidRuntime(277): at android.os.Looper.loop(Looper.java:123)
    09-29 10:52:31.778: E/AndroidRuntime(277): at android.app.ActivityThread.main(ActivityThread.java:4627)
    09-29 10:52:31.778: E/AndroidRuntime(277): at java.lang.reflect.Method.invokeNative(Native Method)
    09-29 10:52:31.778: E/AndroidRuntime(277): at java.lang.reflect.Method.invoke(Method.java:521)
    09-29 10:52:31.778: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    09-29 10:52:31.778: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    09-29 10:52:31.778: E/AndroidRuntime(277): at dalvik.system.NativeStart.main(Native Method)
    09-29 10:52:31.778: E/AndroidRuntime(277): Caused by: java.lang.ClassNotFoundException: com.komal.gcma.PushAndroidActivity in loader dalvik.system.PathClassLoader[/data/app/com.komal.gcma-1.apk]
    09-29 10:52:31.778: E/AndroidRuntime(277): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
    09-29 10:52:31.778: E/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
    09-29 10:52:31.778: E/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
    09-29 10:52:31.778: E/AndroidRuntime(277): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
    09-29 10:52:31.778: E/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
    09-29 10:52:31.778: E/AndroidRuntime(277): … 11 more

  17. Thank you for such great effort…Could you please post another tutorial for the server side?

  18. what is the problem?
    my logcat errors:
    10-06 22:27:21.872: E/AndroidRuntime(278): FATAL EXCEPTION: main
    10-06 22:27:21.872: E/AndroidRuntime(278): java.lang.NoClassDefFoundError: com.google.android.gcm.GCMRegistrar
    10-06 22:27:21.872: E/AndroidRuntime(278): at eyeAppStudios.com.DashboardActivity.onCreate(DashboardActivity.java:59)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.os.Handler.dispatchMessage(Handler.java:99)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.os.Looper.loop(Looper.java:123)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread.main(ActivityThread.java:4627)
    10-06 22:27:21.872: E/AndroidRuntime(278): at java.lang.reflect.Method.invokeNative(Native Method)
    10-06 22:27:21.872: E/AndroidRuntime(278): at java.lang.reflect.Method.invoke(Method.java:521)
    10-06 22:27:21.872: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    10-06 22:27:21.872: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    10-06 22:27:21.872: E/AndroidRuntime(278): at dalvik.system.NativeStart.main(Native Method)

  19. 0-06 22:27:21.872: E/AndroidRuntime(278): FATAL EXCEPTION: main
    10-06 22:27:21.872: E/AndroidRuntime(278): java.lang.NoClassDefFoundError: com.google.android.gcm.GCMRegistrar
    10-06 22:27:21.872: E/AndroidRuntime(278): at eyeAppStudios.com.DashboardActivity.onCreate(DashboardActivity.java:59)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.os.Handler.dispatchMessage(Handler.java:99)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.os.Looper.loop(Looper.java:123)
    10-06 22:27:21.872: E/AndroidRuntime(278): at android.app.ActivityThread.main(ActivityThread.java:4627)
    10-06 22:27:21.872: E/AndroidRuntime(278): at java.lang.reflect.Method.invokeNative(Native Method)
    10-06 22:27:21.872: E/AndroidRuntime(278): at java.lang.reflect.Method.invoke(Method.java:521)
    10-06 22:27:21.872: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    10-06 22:27:21.872: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    10-06 22:27:21.872: E/AndroidRuntime(278): at dalvik.system.NativeStart.main(Native Method)

    help me please

    • You might directly added the ‘gcm.jar’ file from “Build Path” instead of that copy the jar file and add to ‘libs’ folder available at your project creation folder. Then it works fine

    • install apk in GoogleAPI enabled emulator or device

      • Am Installed Google Api Enabled Emulator What OutPut Am Getting Please help me.AM getting only fffff no RegistrationId is Getting.

  20. 10-10 20:25:07.277: W/PackageManager(72): Code path for pkg : com.sagar.gcma changing from /data/app/com.sagar.gcma-1.apk to /data/app/com.sagar.gcma-2.apk
    10-10 20:25:07.277: W/PackageManager(72): Resource path for pkg : com.sagar.gcma changing from /data/app/com.sagar.gcma-1.apk to /data/app/com.sagar.gcma-2.apk
    10-10 20:25:07.277: D/PackageManager(72): Services: com.sagar.gcma.GCMIntentService
    10-10 20:25:07.277: D/PackageManager(72): Receivers: com.google.android.gcm.GCMBroadcastReceiver
    10-10 20:25:07.277: D/PackageManager(72): Activities: com.sagar.gcma.PushAndroidActivityActivity
    10-10 20:25:07.277: D/PackageManager(72): Permissions: com.sagar.gcma.permission.C2D_MESSAGE
    10-10 20:25:07.287: I/ActivityManager(72): Force stopping package com.sagar.gcma uid=10041
    10-10 20:25:07.527: I/installd(34): move /data/dalvik-cache/data@app@com.sagar.gcma-2.apk@classes.dex -> /data/dalvik-cache/data@app@com.sagar.gcma-2.apk@classes.dex
    10-10 20:25:07.527: D/PackageManager(72): New package installed in /data/app/com.sagar.gcma-2.apk
    10-10 20:25:07.557: W/PackageManager(72): Unknown permission android.permission.ADD_SYSTEM_SERVICE in package com.android.phone
    10-10 20:25:07.567: W/PackageManager(72): Not granting permission android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS to package com.android.browser (protectionLevel=2 flags=0x1be45)
    10-10 20:25:07.567: W/PackageManager(72): Unknown permission com.google.android.gm.permission.WRITE_GMAIL in package com.android.settings
    10-10 20:25:07.567: W/PackageManager(72): Unknown permission com.google.android.gm.permission.READ_GMAIL in package com.android.settings
    10-10 20:25:07.599: W/PackageManager(72): Unknown permission com.android.providers.im.permission.READ_ONLY in package com.google.android.apps.maps
    10-10 20:25:07.607: W/PackageManager(72): Unknown permission com.google.android.pushmessaging.permission.RECEIVE in package com.google.android.apps.maps
    10-10 20:25:07.857: I/ActivityManager(72): Force stopping package com.sagar.gcma uid=10041
    10-10 20:25:08.057: D/dalvikvm(72): GC_EXPLICIT freed 11001 objects / 658000 bytes in 178ms
    10-10 20:25:08.357: D/dalvikvm(189): GC_EXPLICIT freed 2868 objects / 148192 bytes in 244ms
    10-10 20:25:08.457: W/RecognitionManagerService(72): no available voice recognition services found
    10-10 20:25:08.537: D/dalvikvm(207): GC_EXPLICIT freed 612 objects / 35584 bytes in 448ms
    10-10 20:25:08.928: D/dalvikvm(72): GC_EXPLICIT freed 4243 objects / 232256 bytes in 158ms
    10-10 20:25:08.967: I/installd(34): unlink /data/dalvik-cache/data@app@com.sagar.gcma-1.apk@classes.dex
    10-10 20:25:08.979: D/AndroidRuntime(571): Shutting down VM
    10-10 20:25:08.997: D/dalvikvm(571): Debugger has detached; object registry had 1 entries
    10-10 20:25:09.049: I/dalvikvm(571): JNI: AttachCurrentThread (from ???.???)
    10-10 20:25:09.049: I/AndroidRuntime(571): NOTE: attach of thread ‘Binder Thread #3′ failed
    10-10 20:25:09.877: D/AndroidRuntime(583): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
    10-10 20:25:09.877: D/AndroidRuntime(583): CheckJNI is ON
    10-10 20:25:10.148: D/AndroidRuntime(583): — registering native functions —
    10-10 20:25:11.167: I/ActivityManager(72): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0×10000000 cmp=com.sagar.gcma/.PushAndroidActivityActivity }
    10-10 20:25:11.257: D/AndroidRuntime(583): Shutting down VM
    10-10 20:25:11.287: D/jdwp(583): Got wake-up signal, bailing out of select
    10-10 20:25:11.287: D/dalvikvm(583): Debugger has detached; object registry had 1 entries
    10-10 20:25:11.347: I/ActivityManager(72): Start proc com.sagar.gcma for activity com.sagar.gcma/.PushAndroidActivityActivity: pid=590 uid=10041 gids={3003}
    10-10 20:25:11.347: I/dalvikvm(583): JNI: AttachCurrentThread (from ???.???)
    10-10 20:25:11.357: I/AndroidRuntime(583): NOTE: attach of thread 'Binder Thread #3' failed
    10-10 20:25:12.079: I/** pushAndroidActivity **(590): registration id =====
    10-10 20:25:12.087: D/GCMRegistrar(590): resetting backoff for com.sagar.gcma
    10-10 20:25:12.107: V/GCMRegistrar(590): Registering app com.sagar.gcma of senders 452450168988
    10-10 20:25:12.397: I/ActivityManager(72): Displayed activity com.sagar.gcma/.PushAndroidActivityActivity: 1141 ms (total 1141 ms)
    10-10 20:25:13.147: V/GCMBroadcastReceiver(590): onReceive: com.google.android.c2dm.intent.REGISTRATION
    10-10 20:25:13.147: V/GCMBroadcastReceiver(590): GCM IntentService class: com.sagar.gcma.GCMIntentService
    10-10 20:25:13.167: V/GCMBaseIntentService(590): Acquiring wakelock
    10-10 20:25:13.197: V/GCMBaseIntentService(590): Intent service name: GCMIntentService-452450168988-1
    10-10 20:25:13.207: E/GCMRegistrar(590): internal error: retry receiver class not set yet
    10-10 20:25:13.207: V/GCMRegistrar(590): Registering receiver
    10-10 20:25:13.227: D/GCMBaseIntentService(590): handleRegistration: registrationId = null, error = PHONE_REGISTRATION_ERROR, unregistered = null
    10-10 20:25:13.227: D/GCMBaseIntentService(590): Registration error: PHONE_REGISTRATION_ERROR
    10-10 20:25:13.227: I/===GCMIntentService===(590): Received error: PHONE_REGISTRATION_ERROR
    10-10 20:25:13.239: V/GCMBaseIntentService(590): Releasing wakelock
    10-10 20:25:18.398: D/dalvikvm(424): GC_EXPLICIT freed 108 objects / 6936 bytes in 150ms
    10-10 20:25:23.417: D/dalvikvm(528): GC_EXPLICIT freed 424 objects / 27712 bytes in 168ms
    10-10 20:25:28.447: D/dalvikvm(259): GC_EXPLICIT freed 84 objects / 3800 bytes in 166ms
    10-10 20:25:33.447: D/dalvikvm(368): GC_EXPLICIT freed 60 objects / 2840 bytes in 142ms
    10-10 20:25:38.487: D/dalvikvm(233): GC_EXPLICIT freed 1611 objects / 103896 bytes in 182ms
    10-10 20:26:01.078: D/SntpClient(72): request time failed: java.net.SocketException: Address family not supported by protocol
    10-10 20:26:17.407: I/EventLogService(233): Aggregate from 1349879352940 (log), 1349879165305 (data)

    Please help me………

  21. can we have JAVA/JSP oriented Server Code ??? anybody can do ???

  22. private void checkNotNull(Object reference, String name) {
    if (reference == null) {
    throw new NullPointerException(
    getString(R.string.error_config, name));
    }
    }
    i am getting error in getString method

  23. Your Blog is Very nice.Am also Using this code but am getting ffffff only not getting any Registration Id.Whats the Wrong. And How can i send and receive Push-notifications.

  24. What Actually am Getting When Run this Project

  25. please help me:
    My LogCat Shown like this:

    02-06 14:43:20.724: I/AndroidRuntime(375): NOTE: attach of thread ‘Binder Thread #3′ failed
    02-06 14:43:21.624: I/ActivityManager(58): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0×10000000 cmp=com.androidhive.pushnotifications/.RegisterActivity }
    02-06 14:43:21.704: I/AndroidRuntime(383): NOTE: attach of thread ‘Binder Thread #3′ failed
    02-06 14:43:26.894: I/ActivityManager(58): Displayed activity com.androidhive.pushnotifications/.RegisterActivity: 5244 ms (total 5244 ms)
    02-06 14:43:28.724: W/InputManagerService(58): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@440cedd0
    02-06 14:43:31.284: W/KeyCharacterMap(316): No keyboard for id 0
    02-06 14:43:31.284: W/KeyCharacterMap(316): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
    02-06 14:43:50.944: I/ActivityManager(58): Starting activity: Intent { cmp=com.androidhive.pushnotifications/.MainActivity (has extras) }
    02-06 14:43:51.053: E/URL(316): > http://localhost/Gcm/
    02-06 14:43:51.333: I/ActivityManager(58): Displayed activity com.androidhive.pushnotifications/.MainActivity: 356 ms (total 356 ms)
    02-06 14:43:52.013: I/GCMIntentService(316): Device registered: regId = APA91bFPkAJO0ymmVok3bPZy9_BOmztLD0vLgBuuSxt9luTO2CeL-yCRJ8y8q66HXOpYZeh2E3GC7Vrk9Ho9eHpi7nZ5xIMOlH83ogW4llEdpFsNGPAgGOS1LRVLnyNOPbZiyxX6f5IfA6hFqr3Ds7FrAXsSu0VQQUx_av6ZRhbP-vddBYPGu8k
    02-06 14:43:52.023: E/URL(316): > http://localhost/Gcm/
    02-06 14:43:53.384: E/URL(316): > http://localhost/Gcm/
    02-06 14:43:54.404: E/URL(316): > http://localhost/Gcm/
    02-06 14:43:58.006: E/URL(316): > http://localhost/Gcm/
    02-06 14:43:59.104: E/URL(316): > http://localhost/Gcm/
    02-06 14:44:07.164: E/URL(316): > http://localhost/Gcm/
    02-06 14:44:08.524: E/URL(316): > http://localhost/Gcm/
    02-06 14:44:25.434: E/URL(316): > http://localhost/Gcm/
    02-06 14:44:27.265: E/URL(316): > http://localhost/Gcm/

  26. i got the registration id now pls tell me how to proceed with this,
    how to use the registration id and send and receive messages

    • Hello Krunal,
      You now need to send this id to your server where it will be saved to the server db and this id will be used to send gcm from server, you just need to use to get the push data and use it accordingly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: