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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:58:30+00:00 2026-06-09T12:58:30+00:00

Well I can not understand why string comparison not working protected String doInBackground(String… args)

  • 0

Well I can not understand why string comparison not working

protected String doInBackground(String... args) 
{
   DefaultHttpClient httpClient =   new DefaultHttpClient();
   HttpPost httpPost            =   new HttpPost(url_login);
   httpPost.setEntity(new UrlEncodedFormEntity(params));
   HttpResponse httpResponse    =   httpClient.execute(httpPost);
   HttpEntity entity            =   httpResponse.getEntity();
   InputStream is               =   entity.getContent();
   String returnState           =   new String();
   returnState                  =   convertStreamToString(is);


   Log.d("retunState ", returnState); // returning desired string

   //if (returnState=="user") // this is not working, however returnState = user
   // OR 
   //if (returnState.equals("user")) 
   // OR
   if (returnState.equalsIgnoreCase("user")) // this is not working also
   {                        
      Intent i = new Intent(Main.this, SecondPage.class);
      startActivity(i);
      finish();
   }

} // close of doInbackgorund function

private 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();
}

Well the all the three if-conditions do not give any error and the second activity never start even if returnState = user or returnState= no_user. I want to start another activity if returnState = user but in any case, it just does not go in if block

  • 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-09T12:58:32+00:00Added an answer on June 9, 2026 at 12:58 pm

    Your first if statement is skipping your next statement as it is false. Comment out the first if.

    Its possible you also have whitespace in your returnState. Try using .trim()

    //if (returnState=="user") 
    if (returnState.trim().equalsIgnoreCase("user")) 
    {                        
       Intent i = new Intent(Main.this, SecondPage.class);
       startActivity(i);
       finish();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, my website can not redirect to https://www.facebook.com/QuaFootSpa from http://quafootspa.com/ I have tried redirection
I have a menu working fairly well but can't figure out how to make
As I understand it, Java does not have true closures. You can pass a
Well I can start the thread when I press togglebutton to ON and it
I`v made my webpart that works well (I can add it to page and
I am trying to parallel a classic map-reduce problem (which can parallel well with
Well im trying to write my own custom control extender but i can't get
Can we do both Principle and as-well-as GratedAuthority in acl_sid and give permissions for
I think I understand well enough what the BindingSource class does - i.e. provide
I studied polymorphism and understand that it can do dynamic method binding like below.

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.