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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:23:59+00:00 2026-05-27T14:23:59+00:00

I have an alarm app with several different alarm types that may be triggered

  • 0

I have an “alarm” app with several different alarm types that may be triggered at any given time. When the alarm goes off it adds a Status Bar Notification. When the user uses the “Clear All” button in the Status Bar, I want the Delete Intent to remove and close the Alarm Activity window from the screen. How can I achieve this? Because my Alarm Activity is NOT a Single Task activity, multiple activity windows can be created at once so I cannot just use an Intent with some data that the onNewIntent() function will run and close the Activity itself. I need to find a way to kill the alarm window from outside of the Activity.

Thanks for your help.

  • 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-27T14:24:00+00:00Added an answer on May 27, 2026 at 2:24 pm

    Hacky but 100% working solution: You can send a Broadcast that all activities are waiting for and that calls finish() on them.

    private String action = "clear";
    private String type = "content://whatever_you_like"; //You should read stuff about this because it's a hack..
    

    onCreate of each Activity:

      clearStackManager = new ClearStackManager();
                registerReceiver(clearStackManager,
                        IntentFilter.create(action, type));
    

    Then define it:

     private final class ClearStackManager extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            finish();
        }
    }
    

    onDestroy:

    unregisterReceiver(clearStackManager);
    

    Calling it:

     public void clearStack() {
        Intent intent = new Intent(action);
        intent.setType(type);
        sendBroadcast(intent);
    }
    

    Out of the box solution: Call by intent the first activity of the stack (if it’s always the same) with FLAG CLEAR_TOP (removing all activities except that one) and then on onNewIntent finish the last one.


    I dunno if it works solution: I also found this: https://stackoverflow.com/a/6403577/327011 but i never worked with actions, so i’m not sure what will happen if multiple activities have the same action.


    UPDATE:

    You should use LocalBroadcastManager instead of “global” Broadcasts to avoid sending global broadcasts.

    http://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html

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

Sidebar

Related Questions

I have an alarm that will not go off until specific hour and minute.
Actually I am Making an Alarm app. In that When i set the Time
The question is very strange: i have done an app that set an Alarm
I have an android app that will record data every x mins. The time
I was wondering if it was possible to have an alarm style app that
I have in mind a simple alarm app for the purpose of hourly alerts/reminders.
I have an android app with the following Alarms setup: Alarm A is of
I have an AlarmReceiver class which executes when alarm rings at a particular time
i have a problem with triggering the multiple alarm at first time , here
I have a code that sets a new repeating alarm (on production I'll use

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.