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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:05:02+00:00 2026-06-04T23:05:02+00:00

I have an application which receives a broadcast from the AlarmManager . Upon this,

  • 0

I have an application which receives a broadcast from the AlarmManager. Upon this, it starts a transparent Activity (AlarmAlertDialogActivity) which then shows an AlertDialog. Clicking cancel on the AlertDialog result in a call to finish().

As the AlarmAlertDialogActivity is not launched from another Activity but a broadcast receiver, it is launched with

Intent.FLAG_ACTIVITY_NEW_TASK

This means the Activity will be launched in a new task.

My problem is that when the app is relaunched from recent history after cancelling the AlertDialog (i.e. by holding the home button and clicking the app’s icon) the AlertDialog is relaunched. I had hoped by using finish()/Intent flags I would be able to avoid this; what I would like to happen is the last Activity before the AlertDialog‘s parent Activity to be launched.

I have tried bitmasking Intent.FLAG_ACTIVITY_NO_HISTORY as an additional flag when launching AlarmAlertDialogActivity but this appears to make no difference.

Bitmasking Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS works, but only by removing the app from the recent history (as the name suggests). This is detrimental to the user experience.

So, is it possible to get the UI flow I am looking for?

UPDATE – more information as requested:

Logcat from Broadcast receiver, the AlertDialog activity and my main activity:

    05-30 10:36:00.132: D/everyOtherApp(362): Received alarm broadcast at: Wed May 30 10:36:00 GMT+00:00 2012
05-30 10:36:00.262: D/everyOtherApp(362): AlarmAlertDialogActivity.onCreate()
05-30 10:36:00.912: D/everyOtherApp(362): AlarmAlertDialogActivity.onResume()
05-30 10:36:12.461: D/everyOtherApp(362): Cancel pressed

//Cancel exits the activity. I now relaunch the app from recent history:

05-30 10:36:20.233: D/everyOtherApp(362): AlarmAlertDialogActivity.onCreate()
05-30 10:36:21.621: D/everyOtherApp(362): AlarmAlertDialogActivity.onResume()

Code for launching Activity from BroadcastReceiver:

        Intent intent = new Intent(new Intent(applicationContext, AlarmAlertDialogActivity.class));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(Constants.SCHEDULED_ALARM_TAG, alarm);
    applicationContext.startActivity(intent);

AlarmAlertDialogActivity in manfest file:

    <activity
        android:name=".AlarmAlertDialogActivity"
        android:theme="@android:style/Theme.NoDisplay" >
    </activity>
  • 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-04T23:05:03+00:00Added an answer on June 4, 2026 at 11:05 pm

    I did something similar in another project. I had a BroadcastReceiver that got information about data connectivity and SIM-Profile changes and showed a dialog (using an activity like yours) warning the user that he might incur charges. What I ended up doing was the following:

    In the manifest, in the <Activity> tag for your AlarmAlertDialogActivity, add the following:

    android:excludeFromRecents="true"
    android:noHistory="true"
    android:taskAffinity=""
    

    Explanation: setting excludeFromRecents and noHistory to “true” ensure that the activity won’t show up in the list of recent applications and also that once the user navigates away from it he won’t be able to go back there (which is probably what you want). Setting taskAffinity to the empty string ensures that AlarmAlertDialogActivity will be run in it’s own task even if your application is running when your dialog is shown.

    As long as you have another activity that functions as the main activity of your application (ie: with intent filters for action.MAIN and category.LAUNCHER) this should solve your problem.

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

Sidebar

Related Questions

I have an application which receives data from a news website (through rss) and
I have an application which receives GPS data from a mobile device as well
I have a networking Linux application which receives RTP streams from multiple destinations, does
I have an application which resides in ROOT. This application has a java class(in
I have an application which periodically receives files and saves them in the internal
I have a web application which receives about 50 hits per second, and on
I have a service / application which receives notifications of Windows session changes. I
I am developing a application which receives 600-700 KB of XML data from the
I have an application containing 4 MDB's each of which receives SOAP messages over
Hi I have an application which after login, loads a main activity which contains

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.