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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:00:19+00:00 2026-05-26T03:00:19+00:00

I’m trying to get the call I just made/received. For that I’m using BroadcastReceiver

  • 0

I’m trying to get the call I just made/received. For that I’m using BroadcastReceiver and IntentServices.

It happens like this:

In my BroadcastReceiver class, I check if the state is OFFHOOK, if yes, I set the flag in SharedPreferences, so When the state becomes IDLE, I check if this flag is still true, if it is, I call the IntentService that goes in CallLog *ContentProvider* and get the lates data like this:

cursor = getContentResolver().query(android.provider.CallLog.Calls.CONTENT_URI, mCursorFields, null, null, android.provider.CallLog.Calls.DATE + " DESC");

cursor.moveToFirst();
cursor.getString(cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
...

Until now it happens perfectly, the only problem is:

“It doesn’t get the latest entry. It gets the next entry, that is the call made before this.”

So, If I made a call before to person ‘X’, in the CallLog is registered this call to person ‘X’. And now, if I make a call to person ‘Y’, instead of it get the call to person ‘Y’, it get’s the call to person ‘X’, that was the call I made before this.

I don’t know what can be happening. It was working perfectly when using ContentObserver but I thought it would be more efficiently built with BroadcastReceiver.

Any idea?

Thanks in advance.


Just a comment about using ContentObserver:

The problem with using ContentObserver is that, If I change the name
of a contact, it detects a change in the CallLog, because the users in
the CallLog with the old name will be updated to the new name, and the
change will occur and call the class. For that I need to make
verifications, for check if it really changed, which I think annoying.

  • 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-26T03:00:19+00:00Added an answer on May 26, 2026 at 3:00 am

    Try delaying the call a bit.
    I believe it takes “a while” until the call log is added.
    ContentObserver is the correct way of handling this as you will be notified when the change occurs.
    If you want to work this way, you will need to delay this in a few seconds after the phone is idle.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to create an if statement in PHP that prevents a single post
I have some data like this: 1 2 3 4 5 9 2 6

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.