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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:26:45+00:00 2026-05-25T03:26:45+00:00

I have used a timer method in an Activity class. In that method I

  • 0

I have used a timer method in an Activity class. In that method I have an intent from Activity class to a BroadcastReceiver class.

This BroadcastReceiver class will call on every 15 minutes at background by using AlarmManager.

When I call the BroadcastReceiver class I would like to raise an AlertDialog.

public void timerMethod(){
    Intent intent = new Intent(Activity.this,
      BroadcastReceiverClass.class
    );

    PendingIntent sender = PendingIntent.getBroadcast(
      QualityCallActivity.this,0, intent, 0
    );

    // We want the alarm to go off 30 seconds from now.
    long firstTime = SystemClock.elapsedRealtime();

    AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
    am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
    firstTime, 60*1000, sender);
}

BroadcastReceiverClass.java

public void onReceive(Context context, Intent intent)
{
    dialogMethod();
}

How can I raise an AlertDialog from BroadcastReceiver class from a background process?

  • 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-25T03:26:45+00:00Added an answer on May 25, 2026 at 3:26 am

    In short: It is not possible.

    Only Activity’s can create/show dialogs. In fact, this has been asked more then once:

    • AlertDialog in BroadcastReceiver
    • How can I display a dialog from an Android broadcast receiver?

    Also, this would give a very bad user-experience:

    • If the user is not in your application (let’s say he’s playing a
      Game) and your Dialog pops up every 15 minutes, this will be very
      annoying for him.
    • If the user is in your application, there are several other (better
      suited) ways to notify him that something has been executed.

    Better suited ways

    In fact, you can create/show a Toast from an BroadcastReceiver. This Toast will also bee shown when the user is not “in your application”.

    Also, you can send a Notification (shown in the Notification-Bar at the top of your screen) from a BroadcastReceiver. A tutorial on how to do this (it does not differ from how you do it in an Activity, except that you use the passed Context-Object from the onReceive-method).

    The Notification will also be shown when the user is not “in your application” and is IMO the best solution to this 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 that receives information from a database, and is used to
I have a function that I have used a bunch of times in various
I used to have a situation where I hit the database a every time
I have a custom view controller that implements the from UITableViewDataSource and UITableViewDelegate protocols.
I have a TFrame (fraDisplay) with a TTimer (timAnimateDataChange). The timer is used to
I have a sprite class which has a draw method which draws an explosion.
This question concerns memory in Android. My method: I have two activites, A and
I want to invoke a method of an object from user defined class for
i have an activity called wipeScreen.java this activity runs a wipeService.java for wiping a
I have used the following statements to get the current time. print $query executed

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.