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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:11:52+00:00 2026-06-05T01:11:52+00:00

I’m wondering how I can access the return statement with a static function. I

  • 0

I’m wondering how I can access the return statement with a static function. I have a static function with Async and I want to then get the return statement in another class – I know it sounds complex but, I’m sure it’s an easy solution.

Login.class

public class LogIn extends Activity {
    Button login;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        TextView top = (TextView) findViewById(R.id.textView2);
        final EditText user = (EditText) findViewById(R.id.etUser);
        final EditText pass = (EditText) findViewById(R.id.etPass);
        CheckBox stay = (CheckBox) findViewById(R.id.cBStay);
        Button login = (Button) findViewById(R.id.btLogin);





    login.setOnClickListener( new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            String user1 = user.getText().toString();
             String pass1 = pass.getText().toString();
            if(user1 !=null &user1.length()>=1 & pass1 !=null &pass1.length()>=1) {
                ComHelper.SendLogin(user1, pass1);

            }
        }
    });


    }



}

ComHelper.class

public class ComHelper extends AsyncTask<String, Void, String> {
    static String adress ="http://gta5news.com/login.php";
    String user;
    String pass;
    public static boolean SendLogin(String user1, String pass1){
    String user = user1.toString();
    String pass = pass1.toString();
    new ComHelper().execute(user1, pass1, adress);
    return true;

    }


    private static StringBuilder inputStreamToString(InputStream is) {
        String line = "";
        StringBuilder total = new StringBuilder();
        // Wrap a BufferedReader around the InputStream
        BufferedReader rd = new BufferedReader(new InputStreamReader(is));
        // Read response until the end
        try {
            while ((line = rd.readLine()) != null) {
                total.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        // Return full string
        return total;

    }



    @Override
    protected String doInBackground(String... params) {
        // TODO Auto-generated method stub
        InputStream inputStream = null;
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost post = new HttpPost(adress);
        try {
            /*Add some data with NameValuePairs */
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("user", user));
            nameValuePairs.add(new BasicNameValuePair("password", pass));
            post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            /*Execute */
            HttpResponse response = httpclient.execute(post);
            String str = inputStreamToString(response.getEntity().getContent())
                    .toString();
            Log.w("HttpPost", str);

            if (str.toString().equalsIgnoreCase("true"))
                return str;

        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {

        }



        return null;




        }
    }

Now, I want to see if ComHelper.SendLogin() returned true/or at least returned something.

EDIT: When the code is executed nothing happens, I guess that’s because I’m not doing anything with the return statement.

  • 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-05T01:11:53+00:00Added an answer on June 5, 2026 at 1:11 am

    If you want to look at the value, then you need to save the return value of the method in a local variable

    if(user1 !=null && user1.length() > 0 && pass1 !=null && pass1.length() > 0) 
    {
         boolean comLogin = ComHelper.SendLogin(user1, pass1);
         if(comLogin)
         {
             //do something
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported

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.