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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:52:30+00:00 2026-05-30T14:52:30+00:00

I have this code: private class DownloadWebPageTask extends AsyncTask<String, Void, String> { @Override protected

  • 0

I have this code:

private class DownloadWebPageTask extends AsyncTask<String, Void, String> 
{
        @Override
        protected String doInBackground(String... theParams) 
        {
            String myUrl = theParams[0];
            final String myEmail = theParams[1];
            final String myPassword = theParams[2];


        Log.d( "Inner myURL: " , myUrl );
        Log.d( "myEmail: " , myEmail );
        Log.d( "myPass: " , myPassword );

        Authenticator.setDefault(new Authenticator()
        {
            protected PasswordAuthentication getPasswordAuthentication() 
            {
                return new PasswordAuthentication( myEmail, myPassword.toCharArray());
            }
        });         

        String response = null;

        try 
        {
            final URL url = new URL(myUrl);
            final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setUseCaches(false);

            final InputStream is = conn.getInputStream();
            final byte[] buffer = new byte[8196];
            int readCount;
            final StringBuilder builder = new StringBuilder();
            while ((readCount = is.read(buffer)) > -1) 
            {
                builder.append(new String(buffer, 0, readCount));
            }

            response = builder.toString();      
            Log.d( "After call, response: " , " " + response);
        } 
        catch (Exception e) 
        {
                Log.d( "Exception: " , "Yup");
                e.printStackTrace();
        }

        return response;
    }       

}

But when its executed, the login/password are not sent in the post request to the server. Any idea how I can fix that and have those parameters sent?

Thanks!

  • 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-05-30T14:52:32+00:00Added an answer on May 30, 2026 at 2:52 pm
    HttpClient client = new DefaultHttpClient();
            try {
                HttpPost httppost = new HttpPost(url);
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    
                nameValuePairs.add(new BasicNameValuePair("user", user));
                nameValuePairs.add(new BasicNameValuePair("password", password));
    
    
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    
                HttpResponse response = client.execute(httppost);
    
                String responseBody = EntityUtils.toString(response.getEntity());
    
                System.out.println("Responce is :: " + responseBody);
    
            } catch (Exception e) {
                e.printStackTrace();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code so far: private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
I have this code private void writeReport(IReport report, string reportName) { string reportString =
I have this code: public class VoiceActivity extends Activity implements OnClickListener { private TextView
Suppose we have this code: class My_controller extends CI_Controller { private $model_name; function __construct($model_name)
I have this snippet of code private Templates retrieveFromCache(String name) { TemplatesWrapper t =
I have this piece of code in c#: private static void _constructRow(SqlDataReader reader, system.IO.StreamWriter
I have this code in a class: private static MyObject _locker = new MyObject();
I have this code /////////////////////////////////////Gnome.cpp file #include Living.h class Gnome:public Living{ private: public: Gnome();
I have this code: private void HandleGUI() { if (_currentForm == null) { navigationSideBar1.Visible
I have this class: public class UploadFile : INotifyPropertyChanged { private string name; public

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.