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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:54:08+00:00 2026-05-23T09:54:08+00:00

Please look at my code.. public class BseDemo extends Activity { final String feedUrlString

  • 0

Please look at my code..

public class BseDemo extends Activity {
    final String feedUrlString = "http://www.bseindia.com/sensex/xml-data/sensexrss.xml";
    Uri uri;
    TextView tvs,tvd;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        Bse b = new Bse();
        b.start();


    }
    class Bse extends Thread{
        public void run(){
            try {
                tvs = (TextView)findViewById(R.id.text);
                tvd = (TextView)findViewById(R.id.diff);
                URL url = new URL(feedUrlString);
                DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                Document doc = docBuilder.parse (new InputSource(url.openStream()));
                doc.getDocumentElement ().normalize ();
                Element e =  doc.getDocumentElement();
                NodeList nl = e.getElementsByTagName("title");
                Node bse = nl.item(2);
                String sen  = bse.getFirstChild().getNodeValue();
                tvs.setText(sen.substring(0, sen.indexOf("*")));
                tvd.setText(sen.substring(sen.indexOf("*")+1));
                tvd.setBackgroundResource(R.drawable.plus);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}

I have code mentioned above and I am getting Exception CalledFromWrongTreadException
please give some solution.

  • 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-23T09:54:09+00:00Added an answer on May 23, 2026 at 9:54 am

    Try to implement a AsyncTask to get the String from the document ( in the doInBackground ) then use the onPostExecute to set the Text on the TextViews.

    Is is the best method on doing background logic without blocking the UI thread.

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

Sidebar

Related Questions

So strange! Please have a look the code first: public class A {} public
Please take a look at this code: class Foo { public $barInstance; public function
My main class look like this: public class Soundboard extends Activity { SharedPreferences preferences;
Please look at simple code below public class A{} public class B: A{} public
First, please look at this custom Button-inherited UserControl code: Public Class UserControl1 Dim _Text
Please have a look at the code below: import string from collections import defaultdict
Please take a look at this code: template<class T> class A { class base
Please look at the following code: #include <iostream> using namespace std; class A {
Please have a look at following code : import java.util.ArrayList; import java.util.List; class Main{
Please look at my sourcecode. public class EntityQuery { public static Func<AdventureWork2008Container, IQueryable<SalesPerson>> selectQuery

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.