Click here to Skip to main content
15,072,933 members
Articles / Mobile Apps
Posted 2 Sep 2013


13 bookmarked

MonoAndroid: Android Notification service

Rate me:
Please Sign up or sign in to vote.
4.69/5 (6 votes)
21 Nov 2013CPOL1 min read
Code for providing notification using Android notification service.


A notification service is the mechanism provided by android system to notify user about from background. Like you updating the applications through Google Play store, its show you message like downloading status or successful updation notification.

Using the code  

Now to achieve this you have to follow these steps :-

  1. Get object of Notification system service using GetSystemService method which of type NotificationManager

  2. Now create Notification object by Passing Application Icon (or any other icon you wish to show to user) and string message which you wish to seen by user like this :-

    Image 1 

  3. Now create PendingIntent object, which will used by notification object to produce message notification. PendingIntent in brief "allows the foreign application to use your application's permissions to execute a predefined piece of code." Bold text is taken from StackOverflow website here

  4. Use SetLatestEventInfo method of notification object with message to be displayed, here second parameter correspond to Header Text and third parameter corresponding smaller text.

  5. Now using NotificationManager notify method display message to User, here is the code for same:- 

var notificationMgr = GetSystemService (Context.NotificationService) as NotificationManager;

var notificationObj = new Notification (Resource.Drawable.Icon, 
                                        "Message From the CodeProject");
var pendingIntentObj  = 
    PendingIntent.GetActivity(this,0,new Intent(this, typeof(MainActivity)),0);

notificationObj.SetLatestEventInfo (this, 
                                    "CodeProject Notification", 
                                    "Message From MonoAndroid",

notificationMgr.Notify (0, notificationObj);

You can clearly see the text "CodeProject Notification" on header text and "Message From MonoAndroid" as smaller text in the image shown below

Image 2

Articles in this Series

Tips/Tricks in this Series


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
India India
He used to have biography here Smile | :) , but now he will hire someone (for free offcourse Big Grin | :-D ), Who writes his biography on his behalf Smile | :)

He is Great Fan of Mr. Johan Rosengren (his idol),Lim Bio Liong, Nishant S and DavidCrow and Believes that, he will EXCEL in his life by following there steps!!!

He started with Visual C++ then moved to C# then he become language agnostic, you give him task,tell him the language or platform, he we start immediately, if he knows the language otherwise he quickly learn it and start contributing productively

Last but not the least, For good 8 years he was Visual CPP MSMVP!

Comments and Discussions

-- There are no messages in this forum --