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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:34:14+00:00 2026-05-24T05:34:14+00:00

I am calling a webservice through asynctask , to call the webservice i am

  • 0

I am calling a webservice through asynctask, to call the webservice i am calling one method named makeRequest() in doInBackground(), I am getting the response in another methods success(), In success method i am updating the listview

But i am getting error like

android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views."

Here Im adding my code.Im calling synctask from activity

new MyTask(this,urlAsString,sp).execute(); 

here is the Asynctask class

class MyTask extends AsyncTask<Void, Void, Void> {
        ProgressDialog progress;

        String url;
        SharedPreferences sp;
        HomepageH2desk c;
          public MyTask(HomepageH2desk context,String url,SharedPreferences sp) {
            this.c = context;
            this.url = url;
            this.sp = sp;
            progress = new ProgressDialog(this.c);
            progress.setMessage("Loading...");
          }

          public void onPreExecute() {
            progress.show();
          }

          public Void doInBackground(Void... unused) {
             c.getTickets(url,sp);
            return null;
            //progress.setMessage("Loading...");
          }

          public void onPostExecute(Void unused) {
            progress.dismiss();
          }
        }

Here im getting webservice response

 public void success(Object result) {

     list = (ArrayList<Map<String, String>>) result;

    this.adapter.setList(list);
            this.adapter.notifyDataSetChanged();
}

listview is not getting updated and showing error

android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

Help me to solve 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-24T05:34:17+00:00Added an answer on May 24, 2026 at 5:34 am

    You should update your List like this.

    Activity_name.this.runOnUiThread(new Runnable() {
    
    @Override
    public void run() {
          list = (ArrayList<Map<String, String>>) result;
          this.adapter.setList(list);
          this.adapter.notifyDataSetChanged();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am calling a webservice and I am getting a complex object back. I
I'm calling a WebService with HttpWebRequest.Create method and read it with StreamReader, (below method
I'm calling a method on a webservice and it is throwing a 403 Forbidden
I am calling my cross domain web-service through a getJson() call from jQuery. As
I need a very basic step by step walk through on calling a webservice
I am calling a webservice from an AsyncTask. It works fine but i'm trying
im calling a webservice with variable response times. I want to be able to
I'm calling my webservice from a web page and getting a timeout despite setting
I need to call an webservice method from my excel macro. can any on
Am calling a webservice from my jQuery to fetch both Staff and Student details.

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.