Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7731731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:33:17+00:00 2026-06-01T06:33:17+00:00

In my application, i have used C2DM. Here, when i receive a C2DM message/notification,

  • 0

In my application, i have used C2DM. Here, when i receive a C2DM message/notification, i am trying to create a notification using notification manager. I can properly create notifications, but i am unable to increment the number of unread notifications(using Notification.number) when there are many unread notifications. Since i am creating notification object inside onReceive() function, its getting destroyed as soon as the control comes out of onReceive function. So, the statements

public class MyC2dmReceiver extends BroadcastReceiver{

private Context context;

@Override
public void onReceive(Context context1, Intent intent) {
this.context = context1;

    if(intent.getAction().equals("com.google.android.c2dm.intent.REGISTRATION")) {    
        handleRegistration(context, intent);
} 
    else if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
        handleMessage(context, intent);
}
}

private void handleMessage(Context context, Intent intent)
{
   .....
   .....   
   Notification notification =     
      new Notification(R.drawable.ic_launcher,intent.getStringExtra("payload"),       
               System.currentTimeMillis());     

   notification.flags |= Notification.FLAG_AUTO_CANCEL;
   notification.defaults = Notification.DEFAULT_ALL;
   notification.number += 1;  
}
}

have been of no use as it is creating a new notification object everytime. I can not make it(notification object) a static object also. If i make it a static object, even after all the unread notifications are viewed, the notification.number does not get reset. This is basically the problem. Could anybody help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:33:18+00:00Added an answer on June 1, 2026 at 6:33 am

    Store your number of unread messages in a database, flat file, shared preference, or other persistent store. Read in that number when creating your new Notification.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application i have used mapview. On particular place i can put annotation.
In my android application i have used the google map. I have using android
I see an application have used Log.info = some info where are these logs
i have used impersonation in this application. whenever this error occurs i required to
i have used progress bar in my application..my application is working fine but the
I have used spring framework 3 for my application. Everything is ok while developed
I have used JMS in the past to build application and it works great.
I have used the andengine.jar file in our application. I have run the physicsexample.
I have used the Validate tool in xcode and validated my application. The validation
I am creating application where in i have used preferences for changing font settings.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.