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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:25:06+00:00 2026-06-09T18:25:06+00:00

I have an application which uses AlarmManager to schedule Notifications if there is any

  • 0

I have an application which uses AlarmManager to schedule Notifications if there is any event coming up. This works well.

The problem is that every time the user instantiates the application, it displays the StatusBar Notification if it is the Event day. I would like to show the StatusBar Notification only when the app is not active (ie. closed).

@Override
public void onCreate(Bundle savedInstanceState)
{
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_calendar_view);

        if (notification_value == true) {
            int dayOfEvent = day;
            if (notification_day == 1) {
                dayOfEvent = day + 1;

            }
            if(isHoliday(dayOfEvent, month, year))
            {
                String mn = monthName[month-1];
                String date_string = setParameter(year, mn, dayOfEvent);
                startAlarm(year, (month-1), day, hour, mins, date_string);
            }
        }
} 
  • 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-09T18:25:08+00:00Added an answer on June 9, 2026 at 6:25 pm

    To prevent AlarmManager from creating Notifications while your app is running simply use AlarmManager.cancel(PendingIntent intent) in onResume() and recreate your alarms in onPause().

    From the Android Documentation on AlarmManager.cancel():

    Remove any alarms with a matching Intent. Any alarm, of any type, whose Intent matches this one (as defined by filterEquals(Intent)), will be canceled.

    This states that you don’t have to keep an references to your old alarms, any alarm with a matching Intent will be cancelled.

    Lastly, I don’t recommend moving the code to onCreate() and onDestory because the app can be paused by the user (with the Home Button for instance) and later killed by the OS. In this case the onDestroy() method is never called. If having Notifications appear while the app is in the background is unacceptable please read this detailed answer on how to track when your app is actually killed: Checking if an Android application is running in the background

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

Sidebar

Related Questions

I have a little application which uses regular expressions under VB6. It works perfectly
We have an application which uses WAMP server. Now, there is a new requirement
Right now I have an application which uses Reporting Services to render reports. This
Note: This may sound dumb. I have an application which uses raw pointers and
we have this application which uses cross app domain (2 app domains in the
I have an application which uses gtkmm. The client's machine does not have this
I have an application which uses Spring and Hibernate. In my database there are
Here's my problem: I have an application which uses sql server express 2005, and
I have an interesting (but frustraring) problem. I have an application which uses the
I have an application which uses Spring 2.5 and Hibernate 3. There's a web

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.