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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:41:07+00:00 2026-05-27T06:41:07+00:00

i have some threads in which i create some views and prepare them to

  • 0

i have some threads in which i create some views and prepare them to be displayed. Among them i also have a WebView. This code is executed in thread:

WebView lGraphWebView = null;
        try{
            lGraphWebView = new WebView(AppController.getAppController());
        }catch (Exception e) {
            Log.d("info", "error: " +e );
        }

and it throws the following exception:

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

This is a bit strange, because when i create a simple button all is OK. So, can anyone explane to me why on creation of a WebView i get this exception and if Looper.prepare() can help here?
Thanks in advance!

  • 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-27T06:41:07+00:00Added an answer on May 27, 2026 at 6:41 am

    In general, its not safe to create view outside of main thread.

    In your particular case, this is not allowed, because WebView creates Handler() in its constructor for communication with UI thread. But since Handler‘s default constructor attaches itself to current thread, and current thread does not have Looper running, you’re getting this exception.

    You might think that creating a looper thread (that must be alive at least as long as WebView) might help you, but this actually a risky way to go. And I wouldn’t recommend it.

    You should stick with creating WebViews in main thread. All controls are usually optimized for fast construction, as they are almost always created in UI thread.

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

Sidebar

Related Questions

I have a simple program which starts n threads and create some load on
I have a parent thread (non-UI) which creates some child threads to do some
I have a parent thread (non-UI) which creates some child threads to do some
I have some code that will be accessed from two threads: class Timer{ public:
We have taken over some .NET 1.1 Windows Service code that spawns threads to
I have some code that runs within a multithreaded class. Basically i create many
I have some unsolved issue with threads. It's my first time doing it. I
I have a custom thread pool class, that creates some threads that each wait
I have inherited a middle tier system with some multi-Threading issues. Two different threads,
I have some thread-related questions, assuming the following code. Please ignore the possible inefficiency

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.