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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:40:31+00:00 2026-06-05T06:40:31+00:00

I have Restful Web Service implemented by Jersey. I connect from Android via HTTP

  • 0

I have Restful Web Service implemented by Jersey.
I connect from Android via HTTP client to fetch the data. It works fine in API level 10 and older versions but not on API level 11 or greater. I appreciate for any help. I have a nullPointerException in these versions.

public String getBaseURI(String str) {
        String result = "";
        try {
            HttpParams httpParameters = new BasicHttpParams();
            int timeoutConnection = 3000;
            HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
            int timeoutSocket = 5000;
            HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
            DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
            HttpGet getRequest = new HttpGet(ServerAddress + str);
            getRequest.addHeader("accept", "application/json");
            HttpResponse response = httpClient.execute(getRequest);
            result = getResult(response).toString();
            httpClient.getConnectionManager().shutdown();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } 
        return result;
    }

private StringBuilder getResult(HttpResponse response) throws IllegalStateException, IOException {
        if (response.getStatusLine().getStatusCode() != 201) 
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
        StringBuilder result = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())), 1024);
        String output;
        while ((output = br.readLine()) != null) 
            result.append(output);
        return result;      
    }

Tag : AndroidRuntime

The logcat exception:

Exception: FATAL EXCEPTION: main
java.lang.NullPointerException
at com.android.internal.os.LoggingPrintStream.Prrintln(LogiingPrintStream.java.298)
at Client.getBaseURI (Client.java:66)

when I call a rest service such as:
String str = client.getBaseURI(“task/project/get/” + user);
I get the Error.

private void listViewSet() {

        ListView lv = (ListView) this.findViewById(R.id.listView);
        lv.setAdapter(new MultiAdapter(this));

        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {

                switch (pos) {
            case ADD:
            String str = client.getBaseURI("task/project/get/" + user);// Json format
                        ......
                }
            }
        });
    }
  • 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-05T06:40:33+00:00Added an answer on June 5, 2026 at 6:40 am

    Are you performing the HTTP request on a separate thread (using an AsyncTask, for example)?

    Some of the newer APIs (especially ICS, in my experience) forcefully require you to perform network connections on a separate thread so as to not block the UI thread. Network connections can be potentially long and expensive, so you never want to perform them on the UI thread. Doing so might prevent the UI from being drawn to the screen, cause your application to force close, make your application appear laggy to the user, etc.

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

Sidebar

Related Questions

I have a ReSTful web service which needs to parse locale-sensitive data from the
I have developed a Mobile application that connect to my Web Servie via RESTful
I have succesfully implemented a RESTful Web Service using the .NET 4.0 framework with
I have a RESTful web service and a rich client application using it. I
I have Restful web-service implemented using Apache CXF. Since I am going to use
I have implemented a generic handler to work as a restful web service in
I have a RESTful web service running on Jersey (GlassFish 3.1.1). This one's a
I have a RESTful web service that returns JSON-serialized data. It can successfully serialize
I have a WCF RESTful web service , I have implemented cache mechanism using
I have a restful web service which can deal with DTOs in json format

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.