1

GCM PushNotification is working fine and no issue in it . I Could able to send and receive back the notifications .

But all i need is to show the count increasing in the mail icon similar to FB like before

enter image description here

and after the notification occur , i want the count to be shown in message

enter image description here

Am using the code as in the link below for notification ,

http://developer.android.com/google/gcm/client.html

Let me know , how this can be made possible . Actually i am searching for the references since yesterday and i am not successful yet . Any related answers are welcomed .

Also i have tried this Refreshing activity on receiving gcm push notification but this didn't worked similar to my case .

I have designed the UI , but i get the issue while setting the value to the textview ( in the red circle ) .

I am setting the text in the onHandleIntent(Intent intent) of GcmIntentService class

but it is crashing saying ,

"You cannot access the view of some other thread"
Community
  • 1
  • 1
VIGNESH
  • 2,023
  • 8
  • 31
  • 46

2 Answers2

0
Create custom view with badge for number of unread messages.
As you receive message update badge

Condition would be :

  1. Check weather user is on same Activity then get activity context and update badge.
  2. If user is not on this activity store count in database and display it when user comes to that activity
Yogesh Lakhotia
  • 888
  • 1
  • 13
  • 26
0

For the count of message received from GCM,you have to intialize a variable like count.And in OnReceive() method after your app notify you just increase the counter value by 1.

And For displaying the count of message to your icon you just looked into the below code..Add new item count to icon on button - Android

Hope it will helps you.

Community
  • 1
  • 1
Born To Win
  • 3,319
  • 3
  • 19
  • 27
  • Have tried all this but how to set the count to the UI button ? That is my issue . – VIGNESH Aug 13 '14 at 11:45
  • try this..http://stackoverflow.com/questions/19234360/android-adding-badge-to-corner-of-drawable-on-a-button – Born To Win Aug 13 '14 at 11:57
  • Design is not my problem , i have designed but the issue is when i set the text to the textview from the onReceive of GSM Notification . It is not possible to access the textview from the receiver . – VIGNESH Aug 13 '14 at 12:05
  • Please first decide what is your question then asked. – Born To Win Aug 13 '14 at 12:06
  • Use Intent(i.e parameter of onReceive() method) to send a counter value to the another activity. – Born To Win Aug 13 '14 at 12:13