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

  • SEARCH
  • Home
  • 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 6879083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:48:10+00:00 2026-05-27T04:48:10+00:00

I have experimented with c2dm and it works adn I am getting message (

  • 0

I have experimented with c2dm and it works adn I am getting message ( I print simple toast ). How to set notification to look the same like notification for gmail for example, to show me in notification area, upper right corner when I get new ? Is there any flag for this or api ? ( At the momemnt I get message in code, extract from intent by key and show toast but there is nothing in notification area ).

  • 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-05-27T04:48:11+00:00Added an answer on May 27, 2026 at 4:48 am

    Within your C2DMReceiver Class which is extended from C2DMBaseReceiver. Put the following code under the override function onMessage, and also write a function named createNotification() which is given below.

    @Override
    protected void onMessage(Context context, Intent intent) {      
        Bundle extras = intent.getExtras();
        if (extras != null) {
            String msg = extras.getString("data.c2dmsg");
            String msgTitle = extras.getString("data.c2dmsgtitle");
            String msgTicker = extras.getString("data.c2dmsgticker");
            createNotification(msgTitle, msg, msgTicker);
        }
    }
    
    
     public void createNotification(String title, String messageText, String tickerttext) {
          int icon = R.drawable.ic_stat_notify_msg; // icon from resources
          CharSequence tickerText = tickerttext; // ticker-text
          long when = System.currentTimeMillis(); // notification time
          Context context = getApplicationContext(); // application Context
          CharSequence contentTitle = title; // expanded message title
          CharSequence contentText = messageText; // expanded message text
          Intent notificationIntent = new Intent(this, HomekhawarActivity.class);
    
          Bundle xtra = new Bundle();
          xtra.putString("title", title);
          xtra.putString("message", messageText);
    
          notificationIntent.putExtras(xtra);
          PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
            notificationIntent, PendingIntent.FLAG_ONE_SHOT
              + PendingIntent.FLAG_UPDATE_CURRENT);
          String ns = Context.NOTIFICATION_SERVICE;
    
          NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
          Notification notification = new Notification(icon, tickerText, when);
          notification.setLatestEventInfo(context, contentTitle, contentText,   contentIntent);
          notification.defaults |= Notification.DEFAULT_LIGHTS;
          notification.defaults |= Notification.DEFAULT_SOUND;
          notification.defaults |= Notification.FLAG_AUTO_CANCEL;
          notification.flags = Notification.DEFAULT_LIGHTS
            | Notification.FLAG_AUTO_CANCEL;
          final int HELLO_ID = rand.nextInt();
          mNotificationManager.notify(HELLO_ID, notification);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like app to add several (2k) words to UserDictionary. I have experimented
I have experimented with a sigmoid and logarithmic fade out for volume over a
I have experimented with several different static analyzers for Java, notably Findbugs and PMD.
I'm new to SVN and have experimented with it locally on my Dreamhost test
The table's schema is pretty simple. I have a child table that stores a
I have setup the Android part for C2DM, and here's a part of the
I have experimented with this: >> code-block: copy [] == [] >> append code-block
I have experimented with a technique that involves a web page request which you
I have run into problems getting my local php and rails development environments to
Cross-posted from the Cukes Google Group: I have experimented with a number of methods

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.