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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:42:24+00:00 2026-05-20T21:42:24+00:00

all i this is my code in notification class which i am calling after

  • 0

all i this is my code in notification class which i am calling after completing my tasks from 1st activity.

But i am getting the problem for getting notification on current application.

I want to show Notification as dialog box.

"R.layout.main" 

contains dialog box with OK button.

public class Notif extends Activity implements View.OnClickListener {

  private Button Button01;

  private NotificationManager mManager;

  private static final int APP_ID = 0; 

  @Override

  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    this.Button01 = (Button) this.findViewById( R.id.Button1);

    this.Button01.setOnClickListener(this);



    mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

  }

  @Override

  public void onClick(View v) {

    Intent intent = new Intent(this,Notif.class);
    Notification notification = new Notification(R.drawable.icon,

    "Notify", System.currentTimeMillis());

       notification.setLatestEventInfo(Notif.this,"App Name","Description of the                     notification",PendingIntent.getActivity(this.getBaseContext(), 0, intent,

PendingIntent.FLAG_CANCEL_CURRENT));

    mManager.notify(APP_ID, notification);

  }

}
  • 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-20T21:42:25+00:00Added an answer on May 20, 2026 at 9:42 pm

    1) Why handle your button listener with an implementation of View.OnClickListener?

    The standard way I have seen so far is:

        Button01.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // Your code
            }
        });
    

    2) Notifications are ways to notify the user through the Android status panel at the top of the screen. I don’t understand what you want to do with Notifications and Dialog Boxes – make up your mind which one you want?

    http://developer.android.com/guide/topics/ui/dialogs.html

    http://developer.android.com/guide/topics/ui/notifiers/notifications.html

    If you do want to use Notifications, then this is what I have in my onStop() method (it’s basically just what you get from following the Android guide):

            Notification notification = new Notification(R.drawable.icon, "App Name", System.currentTimeMillis());
            notification.flags = Notification.FLAG_AUTO_CANCEL;
    
            Intent notificationIntent = new Intent(this, ClassToStart.class);
            PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
            notification.setLatestEventInfo(getApplicationContext(), "App Name", "Press here to resume", contentIntent);
            mNotificationManager.notify(1, notification);
    

    This is with mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); already done in onCreate()

    Really not sure what it is you’re trying to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to connect to Active Directory and get all the groups
I've been trying to get this code to work for hours! All I need
All, this is my code //declare string pointer BSTR markup; //initialize markup to some
im re-factoring php on zend code and all the code is full of $_GET[this]
All this originated from me poking at a compiler warning message (C4267) when attempting
I've managed to mostly ignore all this multi-byte character stuff, but now I need
I'm always surprised that even after using C# for all this time now, I
What's all this business about Flash, Flex, Adobe Air, Java FX and Silverlight? Why
I don't see what all this fuss is about Microsoft's decision to support JQuery
I have a small app that has a Render thread. All this thread does

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.