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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:54:31+00:00 2026-06-13T11:54:31+00:00

Let me first clarify my question. I am doing this,parsing datas (Using DOM) and

  • 0

Let me first clarify my question.

I am doing this,parsing datas (Using DOM) and bind it on my listview. Everything works fine until I found out that it is taking to long to respond. To accomplish that, I come up with an idea that I should put it inside a Thread. So Ive added a class that extends thread.

My code on parsing

  public  void SetFriendString()
{
    XMLParser parser2 = new XMLParser(); 
    parser2.getXmlFromUrl(URL_HERE); 

      //HTTP POST
      String url_Getmembermob= URL_FBFRIEND ;
      //String xml_getMembermob=null;
      try {
      HttpClient httpclient = new DefaultHttpClient();
      HttpPost httppost = new HttpPost(url_Getmembermob);

      List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4); 
      nameValuePairs.add(new BasicNameValuePair("oAuth", "Test123"));
      nameValuePairs.add(new BasicNameValuePair("""", modGen...));
      nameValuePairs.add(new BasicNameValuePair("", modGen....));
      nameValuePairs.add(new BasicNameValuePair("", "here"));

      //Log.i("nameValuePairs", "nameValuePairs=" + nameValuePairs);

        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse httpResponse = httpclient.execute(httppost);

        HttpEntity httpEntity = httpResponse.getEntity();

        FBFRIENDS = EntityUtils.toString(httpEntity);    

        Button GetFriends =(Button) findViewById(R.id.btnAllFriends);
        GetFriends.setBackgroundDrawable(getResources().getDrawable(R.drawable.leftcornerclicked));
        KEY_FRIENDSDATA = FBFRIENDS;

        Log.i("xml-return",""+ FBFRIENDS);

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace(); 
    }catch (ClientProtocolException e) { 
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

And added this class

        public class thread extends Thread {
        public void run() {
            SetFriendString();
            //SetMyRequestString();
            //SetMyFriendRequestString();
            pDialog.dismiss();
            }
        }

Now I am calling this class on my OnCreate

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.my_friends);
    mContext = this;
    pDialog = new ProgressDialog(this);
    pDialog.setMessage("Loading All Merchants...");
    pDialog.setIndeterminate(false);
    pDialog.setCancelable(false);
    pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        pDialog.show();
    //Set All Required data
    thread t = new thread();
    t.start();

Now my app forces to close. Using debugger I found out that the thread skips my methods. Why is that?

10-29 11:13:29.411: E/AndroidRuntime(2463): FATAL EXCEPTION: main
10-29 11:13:29.411: E/AndroidRuntime(2463): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fb.connect/com.fb.connect.MyFriendsAdd}: java.lang.NullPointerException
10-29 11:13:29.411: E/AndroidRuntime(2463):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at android.os.Looper.loop(Looper.java:130)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at android.app.ActivityThread.main(ActivityThread.java:3683)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at java.lang.reflect.Method.invokeNative(Native Method)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at java.lang.reflect.Method.invoke(Method.java:507)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at dalvik.system.NativeStart.main(Native Method)
10-29 11:13:29.411: E/AndroidRuntime(2463): Caused by: java.lang.NullPointerException
10-29 11:13:29.411: E/AndroidRuntime(2463):     at com.fb.connect.MyFriendsAdd.SetAllFacebookFriends(MyFriendsAdd.java:193)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at com.fb.connect.MyFriendsAdd.onCreate(MyFriendsAdd.java:145)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-29 11:13:29.411: E/AndroidRuntime(2463):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-29 11:13:29.411: E/AndroidRuntime(2463):     ... 11 more
  • 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-13T11:54:32+00:00Added an answer on June 13, 2026 at 11:54 am

    Issues I see here:

    1. onCreate() Hasn’t finished yet, when you are showing a dialog.
    2. Calling dismiss() on progressbar, from a thread other than UI thread.
    3. Updating Button from a method , you run on a thread other than UI thread.

    Try using Handler or AsyncTask for this.

    The NPE is at MyFriendsAdd.SetAllFacebookFriends , so you can post that code, to exactly pinpoint the particular cause.

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

Sidebar

Related Questions

Caveats: Let me first clarify that this is not a question about whether to
First off, let me clarify the platforms we are using. We have an ASP.NET
First let me say I have read this useful article thoroughly and am using
Let me clarify my question, and the solution I'm looking for. I'm using wikispaces.com,
Let me first tender my apologies for my question might be too long to
Let me first put the code snippets here. I am just using the ASP.NET
Let me first explain what I'm trying to achieve using some pseudo-code (JavaScript). //
Let me clarify what I mean by 'normal' C++ first- I'm currently reading Walter
I've got a question - BizTalk or WF? And let me clarify that I
Let me first clarify that I am by now very familiar with definitions of

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.