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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:44:43+00:00 2026-06-05T21:44:43+00:00

A user is getting an error on their phone when executing the code below,

  • 0

A user is getting an error on their phone when executing the code below, I am checking to see if the user is currently on a call or not before I run an AsyncTask making a Web Service call. The reason I am doing this is because some people are losing internet connection when on a call so i check every 5 seconds to see if they are on a call or not. If they are not then AsyncTask gets called

do{
        Handler handler = new Handler();
        handler.postDelayed(new Runnable(){

            @Override
            public void run() {

                 onCall = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE))
                        .getCallState() != TelephonyManager.CALL_STATE_IDLE;
                 if(!onCall){
                     new CallRegWS().execute();
                 }  
            }
        },5000);
    }while(onCall);

I do not have the full stack trace only this showing me the error

java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

obviously not too helpful but that is all I have to go on. they keep getting that error so it must be happening when I create the handler.

All this is done in the main thread so I dont know what the problem is, any insight on how I could fix this?

Update
this is called from a service and the method is in a separate class

  • 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-05T21:44:45+00:00Added an answer on June 5, 2026 at 9:44 pm

    Try Handler handler = new Handler(Looper.getMainLooper());

    Also, see this post regarding this error: http://levinotik.com/loopers-handlers-runtimeexceptions-explained/

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

Sidebar

Related Questions

I keep getting this error System.Web.HttpException was unhandled by user code Message=Validation of viewstate
I am getting a syntax error for the code below. I am trying to
Now getting error Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT
I am getting this error when a new user account is getting created: ActiveRecord::StatementInvalid
I am getting error in the sql statement. (server= RAJ-PC\SQLEXPRESS; user id=sa; password=as64ws; database=onlineshopping,
I am getting this error While running this LoadError: Expected /home/user/Desktop/Tripurari/myapp/app/models/host.rb to define Host##
I'm getting following error when I try to log onto phpMyAdmin. User * *
I'm getting the following error in my rails app: comparison of User with User
Sometimes I m getting unicode errors like below in my django site when user
to is not defined [Break on this error] setTimeout('updateChat(from, to)', 1); I'm getting this

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.