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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:27:52+00:00 2026-05-26T00:27:52+00:00

I want to develope a receiver class which will listen Phone state. And I

  • 0

I want to develope a receiver class which will listen Phone state. And I want to work on doSomething() using incoming phone number.

And my need is that my receiver should work between some time interval (like 12:30PM to 01:00PM), other than this time interval my receiver should not work.

What I did yet :

This is my BroadcastReceiver class :

public class MyTest extends BroadcastReceiver {
    protected AudioManager audioManager;// = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
    protected Context context;
    private ITelephony telephonyService;
    @Override
     public void onReceive(Context context, Intent intent) {
      audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
      this.context = context;
      String action = intent.getAction();
             if(action.equalsIgnoreCase("android.intent.action.PHONE_STATE")){
              if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(
                                  TelephonyManager.EXTRA_STATE_RINGING)) {
                  //Incoming call 
               doSomething(intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER));
              }         
             }
             else {

             Bundle bundle = intent.getExtras();
             Object[] pdus = (Object[]) bundle.get("pdus");
             SmsMessage message = SmsMessage.createFromPdu((byte[])pdus[0]);
             if(!message.isEmail())
                 doSomething(message.getOriginatingAddress());

             }

     }
}

And I am using it as in my activity :

registerReceiver(new MyTest(), new IntentFilter("android.intent.action.PHONE_STATE"));

In manifest I declaired it as

<receiver android:name=".MyTest"></receiver>

Problem :

Its working if my application is running on foreground, but when I closes my application its not working.
I didn’t write any code on onPause() or other methods of Activity life cycle.

What am I doing wrong? Is there any other way to this?

  • 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-26T00:27:52+00:00Added an answer on May 26, 2026 at 12:27 am

    Register your receiver in your manifest file like this:

    <receiver android:name=".PhoneStateReceiver">
       <intent-filter>
           <action android:name="android.intent.action.PHONE_STATE" />
       </intent-filter>
    </receiver>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using chilkat socket class. The problem is I want to keep my
I need to learn more about streaming techniques. I am using biztalk and want
I want to develop a keystroke converter which will convert any keystroke into my
I want to develop a mobile web application using asp.net 3.5 that can be
I want to develop an iPhone application using the utility template, where the flip
I try to develope a simple Broadcastreceiver. Here's my code: public class MyClass extends
I want to develop a Generic Extension Method which should arrange the string in
I want to develop a DB structure where every object will go in its
I want to send & receive msg using xmppframework in iphone so I am
I have Threads that listens to incoming HTTP messages , i want to enable

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.