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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:23:31+00:00 2026-05-25T06:23:31+00:00

I’m currently trying to fill a fragment with an asynchronous task. It’s mainly an

  • 0

I’m currently trying to fill a fragment with an asynchronous task. It’s mainly an exercise since the real implementation will get the data out of an SQLite database – however I have to implement the GSON/SOAP sync at some time – and I guess the problem stays the same.

I’m not able to fill my FragmentList after I fetch all the data from the webservice, I get an NullReferenceException – but I can’t really find my mistake.

I don’t get an exception if the webservice isn’t returning any data.

On a Sitenote – why is Android contacting the webservice again when I change the orientation of the phone

public class ClosestPlaces extends FragmentActivity {

private static KantinenListe kantinen;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_ACTION_BAR);        
    setContentView(R.layout.kantinen_results);

}   

/**
 * This is the "top-level" fragment, showing a list of items that the
 * user can pick.  Upon picking an item, it takes care of displaying the
 * data to the user as appropriate based on the currrent UI layout.
 */

public static class TitlesFragment extends ListFragment {
    boolean mDualPane;
    int mCurCheckPosition = 0;


    private class BuildKantinen extends AsyncTask<String, Integer, KantinenListe>   {

        private KantinenListe kantinen;


        @Override
        protected KantinenListe doInBackground(String... params) {
            try{

                Gson gson = new Gson();             
                // SOAP Test
                String NAMESPACE = "http://tempuri.org/";
                String METHOD_NAME = "fullSyncGPS";
                String SOAP_ACTION = "http://tempuri.org/IDatenService/fullSyncGPS";
                String URL = "http://webserviceURL?wsdl";

                SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);

                PropertyInfo pi = new PropertyInfo();
                request.addProperty("radius",10);
                request.addProperty("lat", "14.089201");
                request.addProperty("lng", "02.136459");
                request.addProperty("von", "01.09.2011");
                request.addProperty("bis", "01.09.2011");

                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                envelope.dotNet = true;
                envelope.setOutputSoapObject(request);        

                HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                androidHttpTransport.call(SOAP_ACTION, envelope);
                SoapPrimitive result = (SoapPrimitive)envelope.getResponse();

                String resultData = result.toString(); 


                resultData = "{\"meineKantinen\":"+resultData+"}";
                this.kantinen = gson.fromJson(resultData, KantinenListe.class);
                Log.i("test", "blubber" );
            }
            catch(Exception e)
            {
                 e.printStackTrace();
            }
                return this.kantinen;

        }

        @Override
        protected void onPostExecute(KantinenListe result) {
            // populate the List with the data
            Log.i("test", "postexecute" );
            setListAdapter( new MenuAdapter(getActivity(), R.layout.simple_list_item_checkable_1, kantinen.getMeineKantinen()));
        }
    }


    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        new BuildKantinen().execute("test");                       

        if (savedInstanceState != null) {
            // Restore last state for checked position.
            mCurCheckPosition = savedInstanceState.getInt("curChoice", 0);
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("curChoice", mCurCheckPosition);
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        showDetails(position);            
    }

    /**
     * Helper function to show the details of a selected item, either by
     * displaying a fragment in-place in the current UI, or starting a
     * whole new activity in which it is displayed.
     */
    void showDetails(int index) {
        mCurCheckPosition = index;

            // Otherwise we need to launch a new activity to display
            // the dialog fragment with selected text.
            Log.i("Test",Integer.toString(index));
            Intent intent = new Intent();
            intent.setClass(getActivity(), BeAPartner.class);
            startActivity(intent);
    }
}

public static class MenuAdapter extends ArrayAdapter {

    private LayoutInflater mInflater;
    private List<Kantine> items;
    private Context context;

    public MenuAdapter(Context context, int textViewResourceId, List<Kantine> items) {
        super(context, textViewResourceId);
        mInflater = LayoutInflater.from(context);
        this.items = items;
        this.context = context;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.menu_row, parent, false);
            holder = new ViewHolder();
            holder.color = (TextView) convertView.findViewById(R.id.color);
            holder.title = (TextView) convertView.findViewById(R.id.detail);
            holder.subdetail = (TextView) convertView.findViewById(R.id.subdetail);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        // Fill in the actual story info
        Kantine s = items.get(position);

        s.setName( Html.fromHtml(s.getName()).toString() );
        if (s.getName().length() > 35)
            holder.title.setText(s.getName().substring(0, 32) + "...");
        else
            holder.title.setText(s.getName());

        Log.i("display", "Here I am");
        return convertView;
    }


 }
    static class ViewHolder {
        TextView color;
        TextView title;
        TextView subdetail;
    }   

}

LogCat says the following:

 09-01 17:16:31.830: INFO/test(2104): postexecute
 09-01 17:16:31.830: DEBUG/AndroidRuntime(2104): Shutting down VM
 09-01 17:16:31.830: WARN/dalvikvm(2104): threadid=1: thread exiting with uncaught exception (group=0x40243560)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104): FATAL EXCEPTION: main
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104): java.lang.NullPointerException
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at com.$TitlesFragment$BuildKantinen.onPostExecute(ClosestPlaces.java:117)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at      com..ClosestPlaces$TitlesFragment$BuildKantinen.onPostExecute(ClosestPlaces.java:1)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at      android.os.AsyncTask.finish(AsyncTask.java:417)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at                     android.os.AsyncTask.access$300(AsyncTask.java:127)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at android.os.Handler.dispatchMessage(Handler.java:99)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at android.os.Looper.loop(Looper.java:123)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at android.app.ActivityThread.main(ActivityThread.java:3835)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at java.lang.reflect.Method.invokeNative(Native Method)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at java.lang.reflect.Method.invoke(Method.java:507)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
 09-01 17:16:31.830: ERROR/AndroidRuntime(2104):     at dalvik.system.NativeStart.main(Native Method)
  • 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-25T06:23:31+00:00Added an answer on May 25, 2026 at 6:23 am

    In the code, you are doing nothing but just print stack trace when exception get caught. Your doInBackground() always returns a kantinen. you should examine and handle NULL situation in your onPostExecute()

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I

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.