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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:12:27+00:00 2026-06-15T05:12:27+00:00

i can’t figure out how to retrieve a value from a GetLogin class i

  • 0

i can’t figure out how to retrieve a value from a GetLogin class i have that extends AsyncTask. Here’s my code:

public class GetLogin extends AsyncTask<String, Void, String> {

private final HttpClient httpclient = new DefaultHttpClient();

final HttpParams params = httpclient.getParams();
HttpResponse response;
private String content =  null;
private Context mContext;

public GetLogin(Context context){

    this.mContext = context;

}

protected String doInBackground(String... urls) {

    String result = null;

    try {

        DefaultHttpClient httpClient=new DefaultHttpClient();

        Log.e("Tag", "url: " + urls[0]);

        //Connect to the server
        HttpGet httpGet = new HttpGet(urls[0].toString());

        //Get the response
        HttpResponse httpResponse = httpClient.execute(httpGet);
        HttpEntity httpEntity = httpResponse.getEntity();
        InputStream stream = httpEntity.getContent();

        //Convert the stream to readable format
        result = convertStreamToString(stream);
        Log.e("Tag", "Result: " + result);

        if (result.charAt(1)=='1') {
            return "Login Successful";
        } if (result.charAt(1)=='0') {
            return "Login Failed";
        } else {
            return result.toString();
        }

  //  } catch (ClientProtocolException e) {
  //      Log.w("HTTP2:",e );
 //       content = e.getMessage();
  //      cancel(true);
  //      return "Could not connect to Server";
   //     
   // } catch (IOException e) {
   //     Log.w("HTTP3:",e );
   //     content = e.getMessage();
   //     cancel(true);
   //     return "Could not connect to Server";

    }catch (Exception e) {
        Log.w("HTTP4:",e );
        content = e.getMessage();
        cancel(true);
        return "Could not connect to Server";
    }
}

public static String convertStreamToString(InputStream is) 
{
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();

    String line = null;
    try {
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
    } 
    catch (IOException e) {
        e.printStackTrace();
    } 
    finally {
        try {
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return sb.toString();
}

}

Here’s the code for Login Activity

    String url = "http://192.168.1.107:6972/evalservice/checkLogin?name="+tvUsername.getText()+"&pass="+tvPassword.getText();
    new GetLogin(LoginActivity.this).execute(url);

what i would like to do is put an if statement to see if login was successfull and if so, proceed to the next activity

  • 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-15T05:12:28+00:00Added an answer on June 15, 2026 at 5:12 am

    what i would like to do is put an if statement to see if login was successfull and if so, proceed to the next activity

    Whatever you return from doInBackground(...) is passed to the onPostExecute(...) method of an AsyncTask. Simply check the result in that method and, if successful, have it start the next Activity and finish() the current one.

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

Sidebar

Related Questions

Can I have a project that has some parts written in c and other
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can anyone let me know how can we change the value of kendo combobox
Can I order my users in the database, so I don't have to say
Can we change the default action of the edit selected row button? Here is
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
Can I call select before recv_from on a socket that is blocking?
Can anyone suggest how to underline the title of a UIButton ? I have

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.