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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:20:51+00:00 2026-05-27T13:20:51+00:00

I have just started Android Development, I want to make thread in my application

  • 0

I have just started Android Development, I want to make thread in my application which reads XML document and returns a view which is to be displayed by createTabContent of tabHost.

I tried it but getting exception

12-08 10:33:52.684: E/AndroidRuntime(422): FATAL EXCEPTION: main
12-08 10:33:52.684: E/AndroidRuntime(422): java.lang.NullPointerException
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.widget.TabHost$FactoryContentStrategy.getContentView(TabHost.java:622)
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.widget.TabHost.setCurrentTab(TabHost.java:323)
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:129)
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:453)
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.view.View.performClick(View.java:2408)
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.view.View$PerformClick.run(View.java:8816)
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.os.Handler.handleCallback(Handler.java:587)
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.os.Handler.dispatchMessage(Handler.java:92)
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.os.Looper.loop(Looper.java:123)
12-08 10:33:52.684: E/AndroidRuntime(422):    at android.app.ActivityThread.main(ActivityThread.java:4627)
12-08 10:33:52.684: E/AndroidRuntime(422):    at java.lang.reflect.Method.invokeNative(Native Method)
12-08 10:33:52.684: E/AndroidRuntime(422):    at java.lang.reflect.Method.invoke(Method.java:521)
12-08 10:33:52.684: E/AndroidRuntime(422):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-08 10:33:52.684: E/AndroidRuntime(422):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-08 10:33:52.684: E/AndroidRuntime(422):    at dalvik.system.NativeStart.main(Native Method)
package com.mahesh;

import java.net.URL;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TabHost;
import android.widget.TextView;

public class CricTask extends TabActivity implements TabHost.TabContentFactory{
    TabHost tabHost;
    Context context;
     ScrollView scroll;
     LinearLayout layout;
  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
         tabHost = getTabHost();
        // MaheshActivity main=new MaheshActivity();
         //scroll = new ScrollView(this);
      context=getApplicationContext();
       //layout=new LinearLayout(context);
        tabHost.addTab(tabHost.newTabSpec("Current")
                .setIndicator("Current")
                .setContent(new Intent(this, List1.class)));


        tabHost.addTab(tabHost.newTabSpec("Result")
                .setIndicator("Result").setContent(this));
                //.setContent(new Intent(this, MaheshActivity.class).putExtra("link", "http://www.espncricinfo.com/rss/livescores.xml")));

        tabHost.addTab(tabHost.newTabSpec("News")
                .setIndicator("News")
                .setContent(new Intent(this,MaheshActivity.class)
                        .putExtra("link", "http://www.espncricinfo.com/rss/content/story/feeds/0.xml")));




    }



@Override
public View createTabContent(String tag) {


    if(ta..equals("Current")){
      new Thread(new Runnable() { 
          public void run(){

              XmlHandler handle = null;

                TextView name[];
                TextView website[];

                URL web;

                //setContentView(R.layout.layout);

                 scroll = new ScrollView(context);
                 layout=new LinearLayout(context);
                layout.setOrientation(1);
                //ScrollView scroll = new ScrollView(this);

                try {

                    web = new URL("http://www.espncricinfo.com/rss/livescores.xml");

                        SAXParserFactory factory = SAXParserFactory.newInstance();
                        SAXParser sax = factory.newSAXParser();
                        XMLReader xmlread = sax.getXMLReader();
                        handle = new XmlHandler();
                        xmlread.setContentHandler(handle);
                        xmlread.parse(new InputSource(web.openStream()));

                    }           
                    catch(NullPointerException n){
                                n.getMessage();
                                }

                catch (Exception e) {

                  e.getMessage();

                }
                SitesList sitesList = handle.sitesList;

                name = new TextView[sitesList.getName().size()];
                website = new TextView[sitesList.getName().size()];

                for (int i = 1; i < sitesList.getName().size(); i++) {

                    name[i] = new TextView(context);
                    name[i].setText(sitesList.getName().get(i));
                    name[i].setTextSize(20);
                    name[i].setTextColor(Color.GREEN);
                    website[i] = new TextView(context);

                    String str = "\"" + sitesList.getWebsite().get(i) + "\"";
                    //String link = sitesList.getWebsite().get(i);
                    String html = "<a" + " " + "href" + "=" + "\\" + str + ">"
                            + str + "</a>";

                    website[i].setText(Html.fromHtml(html));
                    website[i].setAutoLinkMask(BIND_AUTO_CREATE);
                    website[i].setTextColor(Color.YELLOW);
                    website[i].setMovementMethod(LinkMovementMethod.getInstance());

                    TextView tv = new TextView(context);
                    tv.setTextColor(Color.CYAN);
                    layout.addView(tv);
                    layout.addView(name[i]);
                    layout.addView(website[i]);

                }
                scroll.addView(layout);
               }


          }).start();

        return scroll;
    }


}

}
  • 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-27T13:20:51+00:00Added an answer on May 27, 2026 at 1:20 pm

    Well, you haven’t posted your code yet, but I am still going to take a stab at this, since you said you are new at developing apps. Are you using the Threadclass? In Android, you need to use AsyncTask instead if you want to update the UI from your Thread process. Be sure to read up on developer.android.com, too. Hope this helps.

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

Sidebar

Related Questions

I have just started Android application development, I have develop the application of Google
I have just started with android in Eclipse and now i want to do
I have just started working on my first Android application and am going ok.
I have just started to develop android application yesterday and having a great fun
I'm just getting started with eclipse and android development. One thing which is driving
I just started make a kind of Android hybrid app, an application with WebView.
I have just started doing Android development on Mac OS X in Eclipse. When
I have just started with android ... I have to develop an android application
I have just started android development 3 days ago and I'm trying to develop
We have just started Android Tablet development. I need to prototype for 7in and

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.