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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:43:44+00:00 2026-05-30T07:43:44+00:00

I need an application wide listener to determine when the service state changes on

  • 0

I need an application wide listener to determine when the service state changes on the phone. I’ve been through every example online, copied line for line, modified the manifest, and I CANNOT get anything to work.

Does a phone state listener HAVE to been in activity? Can I have some plain old class to listen for a phone state change??

This is very frustrating.

In my class I have…

     private class ServiceReceiver extends BroadcastReceiver{

        @Override
        public void onReceive(android.content.Context context, Intent intent) {

            Log.i(TAG, "onReceive");

            MyPhoneStateListener qpsl = new myPhoneStateListener();
            TelephonyManager tm = (TelephonyManager)context.getSystemService(android.content.Context.TELEPHONY_SERVICE);
            tm.listen(qpsl, PhoneStateListener.LISTEN_SERVICE_STATE);
        }
    }

    private class MyPhoneStateListener extends PhoneStateListener{

public void onServiceStateStateChanged(ServiceState serviceState){
    Log.i(TAG, "ServiceState = " + serviceState.getState();
}

I know I need to modify the manifest for the broadcast receiver and phonestate. Where? I want this application wide.

This is all the code I have, can someone show me what I’m missing so that I can listen for a service state change?

  • 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-30T07:43:45+00:00Added an answer on May 30, 2026 at 7:43 am

    I suspect the reason nothing works for you is the broadcast is never received. What broadcast have you registered in manifest? Remember, phone state change is not a “traditional” broadcast. You need to register this PhoneStateListener object instead.

    In any case, you don’t need a BroadcastReceiver for this. Just use a Service instead. Just move the code from onReceive() above into onStartCommand() of a Service and you should be good to go.

    I have implemented something along similar lines in a simple “Poor Signal History” app and it works fine. The project is uploaded here.

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

Sidebar

Related Questions

For an wide application, I need to use localization. I'm planning to use this
I need my application to behave differently depending on whether Vista UAC is enabled
I need my application installer set the program to auto-startup for all users. Then
I need a application to copy text and images form PowerPoint to Word. I
In the java web application need to select the file from server and print
i have an application that has a dependancy on gdiplus. i need the application
Developing a C# .NET 2.0 WinForm Application. Need the application to close and restart
In my Silverlight application, I load all the images I need at application start
I need my .net application to use the .html extension instead of .aspx I'm
In an application I need to execute other programs with another user's credentials. Currently

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.