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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:12:56+00:00 2026-06-11T17:12:56+00:00

I have extended the Application class in my app. In that class, I have

  • 0

I have extended the Application class in my app. In that class, I have a BroadcastReceiver that waits for Connectivity changes. If complete connectivity is lost, I am displaying a specific activity. However, if the app is not “in focus” (not in the foreground), I don’t want to display that activity.

However, the Application class does not have an onPause or onResume method. How can I display this activity ONLY if the app is running? Do I have to have a BroadcastReceiver in all my Acitivities (there’s quite a few of them, and I can’t create an extended Activity for all of them since they extend different Activity classes (Activity, ListActivity, FragmentActivity, etc). Is it possible to only have one BroadcastReceiver where action is taken if and only if one of the app’s Activities is in the foreground?

  • 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-11T17:12:57+00:00Added an answer on June 11, 2026 at 5:12 pm

    I’d say that registering BroadcastReceivers in your custom Application class is an anti-pattern. E.g., when do you unregister that receiver? As you mentioned, the Application class lacks the lifecycle callbacks an Activity has (at least most of them).

    In your case, I’d register the Receiver that handles connectivity changes dynamically, in all of your Activities in the onResume() callback, and unregister them in the onPause() callback. It’s quite possible, that all of your Activities could extend the FragmentActivity: ListAcitivity is just a helper class, you could easily handle all the list-related stuff on your own, and FragmentActivity just extends the basic Activity class.

    So I recommend creating a custom base class for your Activities that handles the Receiver registration, which extends FragmentActivity. All your conrete Activity classes should extend this base class.

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

Sidebar

Related Questions

I have an Activity that pulls an object from an Application extended class (application
I have a WTL application that uses an extended combobox control (the Win32 class
I have an Android app where I've extended the base Application class in order
I have a weird problem: I extended Zend_Log with a class called \Application\Log (it
I'm having troubles extending the Application class to declare global variables. I have extended
I have an AS3 App class e.g (pseudo code) public class MyApp extends Application
I have extended the Application class like this: public class MyApplication extends Application {
I have created an application where I had extended an Activity and got the
I have extended my entities to implement specific interfaces for its type. I am
I have extended the ASP.NET MVC Html Helper to include my own ValidationImage that

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.