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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:30:17+00:00 2026-06-04T17:30:17+00:00

I have made a NotificationView Class to display notification on receiving SMS which works

  • 0

I have made a NotificationView Class to display notification on receiving SMS which works fine but when I click on Notification the it does not clean and the Notification icon remain on Notification Bar but I wish to clean it pl specifies me some hints or sample code for that thanks in advance or sorry for if query is not get cleared..I tag the code

Thanks

The displayNotification method on OnReceive of BroadcastReceiver

private void displayNotification(String msg){
    Intent i = new Intent(this.context,NotificationView.class);
    i.putExtra("ID", ID);
    /*i.putExtra("msg",msg);*/
    PendingIntent pendInt = PendingIntent.getActivity(context, 0, i, 0);
    Notification notif = new Notification(R.drawable.notify,"Receiving SMS",System.currentTimeMillis());
    NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    notif.setLatestEventInfo(context, "SMS", msg, pendInt);
    notif.flags |= Notification.DEFAULT_ALL;
    notif.flags |= Notification.DEFAULT_VIBRATE;
    notif.flags |= Notification.DEFAULT_LIGHTS;
    notif.flags |= Notification.FLAG_AUTO_CANCEL;       
    notif.ledARGB = Color.WHITE;                         
    notif.ledOnMS = 1500;                         
    notif.ledOffMS = 1500;      
    nm.notify(ID, notif);
}

And this is the code for NotificationView class.

public void onCreate(Bundle savedInstanceState){

    super.onCreate(savedInstanceState);
    setContentView(R.layout.notificationview);
    txtNotify = (TextView)findViewById(R.id.txtNotification);
    ID = getIntent().getExtras().getInt("ID");
    /*txtNotify.setText(getIntent().getExtras().getString("msg"));*/
}

private View.OnClickListener txtClick = new View.OnClickListener() {    
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch(v.getId()){
        case R.id.txtNotification:
            NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
            txtNotify.setText("");              
            nm.cancel(ID);          
            nm.cancelAll();
            NotificationView.this.startActivity(new Intent(NotificationView.this,ZigbeeActivity.class));
        }
    }
};
  • 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-04T17:30:19+00:00Added an answer on June 4, 2026 at 5:30 pm

    Why you are using pipe (“|”) in below code

    notif.flags |= Notification.FLAG_AUTO_CANCEL; 
    

    remove it and check

    notif.flags = Notification.FLAG_AUTO_CANCEL; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made an mvc3 application with Windows Authentication. Everything works fine but I
I have made a SSIS package to create an XML file, which works fine
I have made this example and it works fine on a plain aspx webpage.
I have made an AJAX chatroom; and it works in chrome and FF, but
I have made a module which is transmitting but I don't know whether the
I have made my own exception class which derives from runtime_error and is getting
I have made my Actor , but I am unclear on how to take
I have made a class to try exceptions: class precExcp:exception { public: virtual const
I have made a player that plays mp3 and does the job very well
I have made an application in openCVSharp.It works great. I have made the setup/installer

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.