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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:26:41+00:00 2026-06-17T10:26:41+00:00

I am developing an app that logs onto a tomcat server. I am using

  • 0

I am developing an app that logs onto a tomcat server.
I am using a HTTP GET request to do so, and upon successful connection,
the message is displayed via a buffered stream.

The following code, is used to connect.

public String getInternetData() throws Exception {


BufferedReader in = null;
String data = null;

try {
    HttpClient client = new DefaultHttpClient();
    client.getConnectionManager().getSchemeRegistry().register(getMockedScheme());
    URI website = new URI("https://ts.rks.com:8443/kss/login?username=hydm&password=pw1234"); 
    HttpGet request = new HttpGet();
    request.setURI(website);
    HttpResponse response = client.execute(request);
    response.getStatusLine().getStatusCode();

    in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    StringBuffer sb = new StringBuffer("");
    String l = "";
    String nl = System.getProperty("line.separator");
    while ((l = in.readLine()) != null) {
        sb.append(l + nl);
    }
    in.close();
    data = sb.toString();
    return data;
} finally {
    if (in != null) {
        try {
            in.close();
            return data;
        } catch (Exception e) {
            Log.e("GetMethodLogin", e.getMessage());
        }
    }
}

This is the code that is activated when the user logs in via a login activity.
When I go back to the menu screen and try to run another activity that requires the user
to be logged in, it says that the user is not logged in.

Is the connection being disconnected when the user moves away from the activity or am I not establishing the connection correctly.

  • 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-17T10:26:42+00:00Added an answer on June 17, 2026 at 10:26 am

    There are actually two things you need to change, not just one.

    Anything that you need to have persistent across Activities should be done in a Service, not in the code of an Activity.

    Second, on recent Android releases, all networking must be done from background threads, rather than the UI thread (there was always a recommendation against UI thread networking, but now it triggers an exception). Just putting the code in a Service does not mean it is in another thread.

    So the answer is that you should be doing this using one of the background threading mechanisms, and doing that within a Service.

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

Sidebar

Related Questions

I'm developing an app that periodically fetches data from server. Now I'm using a
I'm developing an app (Flash/AS3) that connects to Facebook. After the user logs in
I'm developing an app that has a model using race results / times etc..
I'm developing an app that will make extensive HTTP requests. I know for a
I'm developing an app for iPad (using Titanium Appcelerator) that is designed to record
I'm developing a Mac App in Java that logs into any one of our
In my winforms app, I'm using a 3rd party library that logs to Console.Error.
I'm developing an app that receive contente (URI) and I'm testing it with IE10
I am developing an app that needs the chat functionality, presenting messages sent and
(I am developing an app that presents chat messages in a table. But, this

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.