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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:52:41+00:00 2026-05-23T07:52:41+00:00

At the moment I am developing an application which catches the action NEW_OUTGOING_CALL with

  • 0

At the moment I am developing an application which catches the action NEW_OUTGOING_CALL with the help of a BroadcastReceiver. I am aborting the call by calling setResultData(null). After that I am showing the user a dialog which allows him to decide if he wants to use my application to rewrite its number. When the users decision has happened I am placing the new call depending on the decision. Now my broadcast receiver gets called up once again.

What is the correct way of getting to know that I have already processed the number? I got a working solution that uses a timestamp to guess if it could be already processed. Another solution would be to add a "+" at the end of the processed number.
These methods are working fine for my application being the only one catching the NEW_OUTGOING_CALL event. But what should I do when other applications (like Sipdroid or Google Voice) are also sitting there catching the NEW_OUTGOING_CALL broadcast aborting it and restarting it again? I don’t see a possibility to get to know if we are still in the same “call flow” and if I already processed the number.

I would love to hear your ideas about this problem!

  • 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-23T07:52:41+00:00Added an answer on May 23, 2026 at 7:52 am

    What API level are you working with? If it’s >= 11, check out the new BroadcastReceiver.goAsync function that lets you extend the processing of the broadcast outside of the onReceive function of your receiver. This could bypass the need to loop altogether.

    If, like me, you’re stuck trying to do this before level 11, it is surprisingly tricky to do this elegantly. You may have done this as well, but I tried to include a “processed” flag as an extra in the ACTION_CALL intent that my code generated, hoping that it would somehow get included in the resulting ACTION_NEW_OUTGOING_CALL broadcast, but that sadly does not work.

    The best solution I have been able to find is including a fragment in the URI for the ACTION_CALL intent that you generate. This fragment will be included for the resulting ACTION_NEW_OUTGOING_CALL broadcast, so your broadcast receiver can differentiate between the original call and the one that you generate, but it won’t interfere with handlers that aren’t looking for it.

    Here’s the basic code.

    In your BroadcastReceiver for the ACTION_NEW_OUTGOING_CALL

    public class YourBroadcastReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            // extract the fragment from the URI
            String uriFragment = Uri.parse(
                intent.getStringExtra("android.phone.extra.ORIGINAL_URI")).getFragment();
    
            // if the fragment is missing or does not have your flag, it is new
            if (uriFragment == null || !uriFragment.contains("your_flag")) {
    
                // launch your activity, pass the phone number, etc.
                // use getResultData to get the number in order to respect
                // earlier broadcast receivers
                ...
    
                // abort the broadcast
                this.setResultData(null);
                this.abortBroadcast();
            }
            // otherwise, your code is there, this call was triggered by you
            else {
                // unless you have a special need, you'll probably just let the broadcast
                // go through here
    
                // note that resultData ignores the fragment, so other receivers should
                // be blissfully unaware of it
            }
        }
    }
    

    When the user first dials the number, the fragment will either be missing altogether or your flag won’t be present, so you’ll abort the broadcast and start your activity. In your activity, if you decide to place the call again, do something like the following:

    startActivity(new Intent(Intent.ACTION_CALL,
                             Uri.parse("tel:" + modified_number + "#your_flag")));
    

    The “your_flag” fragment will then be present in the subsequent NEW_OUTGOING_CALL broadcast and thus allow you to handle this case differently in your broadcast receiver.

    The nice thing about this is the the fragment is completely ignored unless you look for it in the ORIGINAL_URI, so other broadcast receivers can continue to function. If you want to be really nice, you may want to look for an existing fragment and add your flag to it (perhaps with a comma separator).

    I hope that helps. Good luck!

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

Sidebar

Related Questions

I am developing an application which at the moment queries a (rather large) database
I'm developing on an application at the moment which contains quite a lot of
I'm developing a web application similar to Digg and I need an algorithm which
I'm currently developing an application which uses the iTunes COM (Win32) to hook into
I am about 70% of the way through developing a web application which contains
At the moment I'm developing a web based application using Silverlight 3.0. For the
I am developing a web application, in which I have used session management to
I am developing an application which will be used to scan the barcode from
We are developing a web application which is available in 3 languages. There are
I am developing a fairly process hungry application which I need to take an

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.