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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:19:39+00:00 2026-06-06T09:19:39+00:00

I want to block a specific phone number that is in my database I

  • 0

I want to block a specific phone number that is in my database

I do a comparison between the number the user dialed, and the number in memory. If they are equal, I block the call.

My code:

public void onReceive(Context context, Intent intent) {

    PlaceDataSQL placeDataSQL =new PlaceDataSQL(context);
    ArrayList<String> getUsersPhoneNumbers= placeDataSQL.getUsersPhoneNumbers(); 
    //TODO
    //===========
    //here I need to check the number

    Bundle b = intent.getExtras();
    String incommingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
    //String outGoingNumber = b.getString(TelephonyManager.);
    Boolean find=false;
    try {

        for(int i=0;i<getUsersPhoneNumbers.size();i++)
        {
            if(incommingNumber.equals(getUsersPhoneNumbers.get(i)))
            {
                find=true;
                break;
            }
        }

    } catch (Exception e) {
        incommingNumber="";
    }


// ========================================
//here the problem
//=========================================
    String phonenumber=b.getString(Intent.EXTRA_PHONE_NUMBER);
    try {

        for(int i=0;i<getUsersPhoneNumbers.size();i++)
        {
            if(phonenumber.equals(getUsersPhoneNumbers.get(i)))
            {
                find=true;
                break;
            }
        }
        if (!find)
            return;
    }catch (Exception e) {
        phonenumber="";
    }

    if (!find)
        return;


    /* examine the state of the phone that caused this receiver to fire off */
    String phone_state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
    if (phone_state.equals(TelephonyManager.EXTRA_STATE_RINGING)) 
    {

        logMe("Phone Ringing: the phone is ringing, scheduling creation call answer screen activity");
        Intent i = new Intent(context, CallAnswerIntentService.class);
        i.putExtra("delay", 100L);
        i.putExtra("number", incommingNumber);
        context.startService(i);
        logMe("Phone Ringing: started, time to go back to listening");


    }

    if (phone_state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK))
    {

        Intent i = new Intent(context,InCallScreenGuardService.class);
        i.putExtra("delay", 100L);
        i.putExtra("number", phonenumber);
        logMe("Phone Offhook: starting screen guard service");
        context.startService(i);

    }

    if (phone_state.equals(TelephonyManager.EXTRA_STATE_IDLE))
    {
        Intent i = new Intent(context,InCallScreenGuardService.class);
        logMe("Phone Idle: stopping screen guard service");
        context.stopService(i);

    }

    return;
}

The problem:

I can get incoming numbers but I can’t get outgoing numbers?

  • 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-06T09:19:40+00:00Added an answer on June 6, 2026 at 9:19 am

    You will need a BroadcastReciever for this.

    public class OutgoingCallReceiver extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            Bundle bundle = intent.getExtras();
    
            if(null == bundle)
                return;
    
            String phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    
            Log.i("OutgoingCallReceiver",phonenumber);
            Log.i("OutgoingCallReceiver",bundle.toString());
    
            String info = "Detect Calls sample application\nOutgoing number: " + phonenumber;
    
            Toast.makeText(context, info, Toast.LENGTH_LONG).show();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to block the current page when a specific ajax call is made
I want to block special character in this code. In other words, user can
I want to assign a specific menu in left sidebar block, based on the
In Django's templates system, if I have a block that I want to make
I want to make an app that can block all explicit HTTP content on
In a specific template i want to use a block, so it's contents can
I want to retrieve list of all file in a specific folder that included
I want to use a try-catch block to handle two cases: a specific exception,
I want to block an entire ip range from my webserver but I'm not
I want to block non-browser clients from accessing certain pages / successfully making a

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.