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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:47:16+00:00 2026-05-26T09:47:16+00:00

I am trying to implement a background service to transmit logs from a calllog

  • 0

I am trying to implement a background service to transmit logs from a calllog database to a server and I have tried out a lot of things … timer, a thread Looping infinitely… but it seems nothing works… the following program could be loop of timer… but both of them fail on some of the phones… Both of the implementations follow the same methodology but a different implementation(Obviously)… so my question is am i NOT checking out some condition that is causing this fault of not being able to send data …. i understand that the data stops sending when in sleep but almost all the phones resume data transmission but some dont ….

The programming structure .

    public class BootableService extends Service{
           @Override
           public IBinder onBind(final Intent intent) {

                  return null;
           }
           @Override
           public void onCreate() {

                  super.onCreate();
                  // use this to start my infinite thread here which is initialised inside this service class       
           }                    
           @Override
           public void onStart(final Intent intent, final int startId) {

                 //Use this to start a telophony listener that respond to call state and add the call from the call log to a blocking queue .... 

                 telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

                 // Create a new PhoneStateListener
                 listener = new PhoneStateListener() {

                        @Override
                        public void onCallStateChanged(int state, String incomingNumber) {

                            switch (state) {

                                case TelephonyManager.CALL_STATE_IDLE:
                                     System.out.println("phone IDLE");
                                     // calls a function to add the events to a queue. that have not been sent already. 
                                     addtoQueue();                                    
                                     break;
                                case TelephonyManager.CALL_STATE_OFFHOOK:
                                   System.out.println("Phone in use");
                                   break;
                                case TelephonyManager.CALL_STATE_RINGING:
                                   System.out.println("Phone Ringing");
                                       break;
                            }

                        }
                 };
                 // Register the listener wit the telephony manager
                 telephonyManager.listen(listener, PhoneStateListener.LISTEN_CALL_STATE);
          }
          addToQueue()
          {
             //add to the queue add the call log not already transmitted to the server. 
          }

          class handler HandleStuff{

               this handles the data coming from the thread .,,,, the ID of the record sent. straight from the Android call log database.  and store it. 
          }

          Class ThreadRunning extends thread{

                run(){
                     while(true){
                         // This implements take the elements from the queue if present 
                         transmit 1 record/// 
                         sleep(20 seconds.)
                     }
                }
         }
}

the logic is triggered only once. when the phone gets started or when the app is installed/opened. if the service is not already opened.

  • 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-26T09:47:17+00:00Added an answer on May 26, 2026 at 9:47 am

    Why not just use an IntentService. That way you don’t have to deal with all of the threading. All of your code you put in your onHandleIntent() method will be done on a seperate thread and you can take as long as you want.

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

Sidebar

Related Questions

I have the following problem. Background I'm trying to implement an autocomplete selector with
Background I have made a Web Service in Visual Studio, and I'm trying to
Background I'm trying to implement a simple web server part as a web interface
I'm trying to implement a design in CSS that will have a tiled background
Am trying to implement a generic way for reading sections from a config file.
I am trying to implement a fixed background for a website like one over
Background: I'm trying to implement a tab control. The tabs are as follows: |
Background I'm trying to implement block file locking in my C# application. The built-in
I am currently trying to implement a Swing component, inheriting from JLabel which should
I have spent two day trying to figure it out. I have implemented two

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.