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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:54:23+00:00 2026-06-08T07:54:23+00:00

I built an application for Android to auto-login to a specific Guest wireless network.

  • 0

I built an application for Android to auto-login to a specific Guest wireless network. I wanted this application to work and run even when the UI/Activity is not shown/running.

Currently it seems to work well, however I’m questioning the logistics of the design. My questions are:

  • Do I even need a service?
  • Is my design backwards? Should the Broadcast Receiver call the service to do the work?
  • Can you register the broadcast receiver in the manifest and not have to call it at all in code?
  • Are multiple calls to startService() bad? I know only 1 service runs, but how do I check if the service is already running before creating it?

The application has 3 components:

  1. Activity – which has a GUI for displaying current network information and Close / “Stop Service” buttons
  2. Service – all this service does is register a broadcast receiver
  3. Broadcast Receiver – this is what does most of the work. 3.

    • The Activity’s onCreate() calls the Context.startService()
    • The Service onCreate() creates a notification icon and registers the broadcast receiver
    • The Broadcast Receiver onReceive() checks if the network state has changed intent, then checks if currently connected to a specific SSID, then calls a special class I made to register / check if authenticated.
  • 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-08T07:54:24+00:00Added an answer on June 8, 2026 at 7:54 am

    Do I even need a service?

    It depends. If the work you are doing within the BraodcastReceiver doesn’t take much time then you can do it there. However, if your onReceive() runs too long then Android will kill it. In general you shouldn’t do network I/O within the BroadcastReceiver. So you can use the BroadcastReceiver to just kick off your service and it can do the real work.

    Is my design backwards? Should the Broadcast Receiver call the service
    to do the work?

    See my answer to the first question (above)

    Can you register the broadcast receiver in the manifest and not have
    to call it at all in code?

    Yes, you can add an <intent-filter> tag to the <receiver> tag in the manifest. This will start your BroadcastReceiver automatically whenever the appropriate Intents are broadcast. Your application does not need to be running to have this happen. Something like this:

        <receiver
                android:name=".MyReceiver" >
            <intent-filter>
                <action android:name="android.net.wifi.STATE_CHANGE"/>
            </intent-filter>
        </receiver>
    

    Are multiple calls to startService() bad? I know only 1 service runs,
    but how do I check if the service is already running before creating
    it?

    Multiple calls to startService() are fine. If it is already started, it won’t start another one. Each call to startService() generates a call to onStartCommand() in your service. If you want to see if it is already running, you can use peekService() from your BroadcastReceiver. This will return an IBinder if it is running, but won’t start it if it isn’t already running.

    Also see android.net.wifi.STATE_CHANGE: not triggered on Wifi disconnect

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

Sidebar

Related Questions

We are very familiar with the built-in Maps application on Android and I wanted
I am implementing a login system for an Android application utilizing the built-in accounts
Hello, i'm try to make an auto run application in android, Example : App
I have a simple Android application that uses a JAR I have built. When
I want to build an android application, this application allow the users to answer
I have an application built using PhoneGap (Android) that is essentially a shell for
I am working on an Android application where I deliver some built-in images and
I have an Android application that is by default built with Ant. There is
I have built an Android application using PhoneGap and for tweeting I have used
I've built an Android application in eclipse. Before starting the project I selected the

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.