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 9000477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:18:57+00:00 2026-06-16T00:18:57+00:00

I need to create a simple notification which will be shown in notification bar

  • 0

I need to create a simple notification which will be shown in notification bar along with the sound and icon if possible? I also need it to be compatitible with Android 2.2, so i found that NotificationCompat.Builder works with all APIs above 4. If there’s a better solution, feel free to mention it.

  • 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-16T00:18:58+00:00Added an answer on June 16, 2026 at 12:18 am

    The NotificationCompat.Builder is the most easy way to create Notifications on all Android versions. You can even use features that are available with Android 4.1. If your app runs on devices with Android >=4.1 the new features will be used, if run on Android <4.1 the notification will be an simple old notification.

    To create a simple Notification just do (see Android API Guide on Notifications):

    NotificationCompat.Builder mBuilder =
        new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.notification_icon)
        .setContentTitle("My notification")
        .setContentText("Hello World!")
        .setContentIntent(pendingIntent); //Required on Gingerbread and below
    

    You have to set at least smallIcon, contentTitle and contentText. If you miss one the Notification will not show.

    Beware: On Gingerbread and below you have to set the content intent, otherwise a IllegalArgumentException will be thrown.

    To create an intent that does nothing, use:

    final Intent emptyIntent = new Intent();
    PendingIntent pendingIntent = PendingIntent.getActivity(ctx, NOT_USED, emptyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    

    You can add sound through the builder, i.e. a sound from the RingtoneManager:

    mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
    

    The Notification is added to the bar through the NotificationManager:

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(mId, mBuilder.build());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create some simple effects for the layers which I have created
I need to create a simple application that would generate reports based on database
I need to create a simple drawing program in c for graphs, i.e. nodes
I need to create a simple Chat system like facebook chat and a twitter-like
I need to create a simple mySQL database with a field for an image.
For the purpose of the question I need to create a simple fictitious scenario.
Sometimes you need to create a very simple single file application in Qt4. However
How to create simple PHP COMET server page displaying current time? I need code
I need to understand how to create a simple animation in HTML 5 or
With this code we can create a simple word document but I need to

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.