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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:39:45+00:00 2026-05-22T22:39:45+00:00

Hi just wanted to share my notification builder for android the answer is below.

  • 0

Hi just wanted to share my notification builder for android
the answer is below.

Please share any changes.

  • 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-22T22:39:46+00:00Added an answer on May 22, 2026 at 10:39 pm

    minimal usage :

    NotificatorFacade nb = new NotificatorFacade(context);
    nb.show(R.drawable.icon, "tickerText", new Date().getTime(), 
                     "contentTitle", "contentText", ERROR_NOTIFICATION_ID);
    

    source:

    
    package my.tools.android.notification;
    
    import android.app.Notification;
    import android.app.NotificationManager;
    import android.app.PendingIntent;
    import android.content.Context;
    import android.content.Intent;
    import android.net.Uri;
    
    public class NotificatorBuilder {
    
        private final Context context;
        private Intent intent;
        private Integer flags;
    
        private Integer defaults;
        private Uri sound;
    
        public NotificatorBuilder(Context context) {
            this.context = context;
    
        }
    
        /**
         * sets the flags for Notification.defaults
         * 
         * @param defaults
         */
        public void setDefaults(int defaults) {
            this.defaults = defaults;
        }
    
        /**
         * displays the notification with the given parameters it sets
         * notification.flags|=Notification.FLAG_AUTO_CANCEL when intent (setIntent)
         * is null the setIntent functionality was not tested
         * 
         * @see http
         *      ://developer.android.com/guide/topics/ui/notifiers/notifications.
         *      html
         * @param iconDrawable the icon
         * @param tickerText 
         * @param when 
         * @param contentTitle
         * @param contentText
         * @param NOTIFICATION_ID this id is used for later identification 
         */
    
        public void show(int iconDrawable, CharSequence tickerText, long when,
                CharSequence contentTitle, CharSequence contentText,
                int NOTIFICATION_ID) {
            // Get a reference to the NotificationManager:
            String ns = Context.NOTIFICATION_SERVICE;
            NotificationManager mNotificationManager = (NotificationManager) context
                    .getSystemService(ns);
            // Instantiate the Notification:
            Notification notification = new Notification(iconDrawable, tickerText,
                    when);
            // Define the Notification's expanded message and Intent:
    
            if (sound == null) {
    
                notification.sound = sound;
            }
            if (flags != null) {
                notification.flags = flags;
            }
            if (defaults != null) {
                notification.defaults = defaults;
            }
            // if intent null create one and set the FLAG_AUTO_CANCEL flag EXTENDS
            // FLAGS!!!
            if (intent == null) {
                setIntent(new Intent(context, NotificatorBuilder.class));
                notification.flags |= Notification.FLAG_AUTO_CANCEL;
            }
    
            PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                    intent, 0);
    
            notification.setLatestEventInfo(context, contentTitle, contentText,
    
            contentIntent);
    
            mNotificationManager.notify(NOTIFICATION_ID, notification);
    
        }
    
        /**
         * sets the flags for notification usage: NotificatorBuilder nb = new
         * NotificatorBuilder(context);
         * nb.setFlags(Notification.DEFAULT_VIBRATE|Notification.FLAG_INSISTENT);
         * 
         * @param flags
         */
        public void setFlags(int flags) {
            this.flags = flags;
        }
    
        /**
         * sets the intent for
         * 
         * PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
         * intent, 0); notification.setLatestEventInfo(context, contentTitle,
         * contentText,contentIntent); this functionality was not tested
         * 
         * @param intent
         */
        public void setIntent(Intent intent) {
            this.intent = intent;
        }
    
        /**
         * sets the sound for the notification was not tested but should work usage
         * for default  notification call the method :setDefaults(Notification.DEFAULT_SOUND);
         * usage: 
         * To use a different sound with your notifications, pass a Uri reference to
         * the sound field. The following example uses a known audio file saved to
         * the device SD card: 
         * notification.sound =
         * Uri.parse("file:///sdcard/notification/ringer.mp3");
         * 
         * In the next example, the audio file is chosen from the internal
         * MediaStore's ContentProvider: notification.sound =
         * Uri.withAppendedPath(Audio.Media.INTERNAL_CONTENT_URI, "6");
         * 
         * @param sound
         */
        public void setSound(Uri sound) {
            this.sound = sound;
        }
    
    }
    
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wanted to share this Query class and get your thoughts on it.
Just wanted to get an idea for ways (web) developers get round the short
just wanted to gather different ideas and perspectives as to which layer should (and
Just wanted to know if it is possible to disallow the whole site for
Just wanted opinions on a design question. If you have a C++ class than
Just wanted to know if anyone is really using Objects and Collections in Oracle
Just wanted to know if there is a big chance to inject SQL While
Just wanted to know if overriding UITabBarController would get my app rejected? Is it
Just wanted to write some recursion but can't check if the child is in
Just wanted your expert opinions on declarative transaction management for Spring. Here is my

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.