FAQ
Hi... i too with same problem..
On Wednesday, 29 August 2012 23:39:18 UTC+5:30, bats wrote:

Hi,

I have created a sample application to push notifications to android
emulator. I am getting a success response when i use my server to push
data. However, the notification never appears on my android. I am guessing
the problem is with the way i handle notifications in my OnMessage()
callback function of GCMIntentService file. Here is the code that i have in
my onMessage. Please look into it and let me know what i am doing wrong.
Basically, on receiving a message, i just start a new activity.

Thanks

CODE
----------------------------------


@Override
protected void onMessage(Context context, Intent intent) {
String msg = intent.getStringExtra(Constants.FIELD_MESSAGE);
Log.i("====MSG====", "Msg received from GCM: "+msg);
Intent notificationIntent = new Intent(context, MessageActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context,
0, notificationIntent,
PendingIntent.FLAG_CANCEL_CURRENT);
NotificationManager nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Resources res = context.getResources();
Notification.Builder builder = new Notification.Builder(context);
builder.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.ic_stat_cloud)
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentTitle("Title")
.setContentText(msg);
Notification n = builder.build();

nm.notify(R.id.notification_id, n);
}
--
You received this message because you are subscribed to the Google Groups "android-gcm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-gcm+unsubscribe@googlegroups.com.
To post to this group, send email to android-gcm@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-gcm/9562f069-ed06-46ee-bdcb-61f274aa7bad%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupandroid-gcm @
categoriesandroid
postedJun 21, '13 at 7:45a
activeJun 21, '13 at 7:45a
posts1
users1
websitedeveloper.android.com...

1 user in discussion

Sandeep chowdary: 1 post

People

Translate

site design / logo © 2019 Grokbase