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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:05:25+00:00 2026-05-30T10:05:25+00:00

I have this code: package com.problemio; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList;

  • 0

I have this code:

package com.problemio;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class LoginActivity extends Activity 
{
    private TextView textView;

    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);

        // Show form for login_email
        final EditText loginEmail = (EditText) findViewById(R.id.login_email);  
        String name = loginEmail.getText().toString();  

        // Show field for password  
        final EditText password = (EditText) findViewById(R.id.password);  
        String text = password.getText().toString();                  

        // Show button for submit
        Button submit = (Button)findViewById(R.id.submit);   




        // Show options for create-profile and forgot-password

        //readWebpage( R.layout.login) ;


        submit.setOnClickListener(new Button.OnClickListener() 
        {  
           public void onClick(View v) 
           {
              String email = loginEmail.getText().toString();
              String pass = password.getText().toString(); 
              sendFeedback(pass, email);
            }
        });        
    }


    public void sendFeedback(String pass , String email) 
    {  
        Log.d( "1" , pass );
        Log.d( "1" , email );

        String[] params = new String[] { "url", email, pass };


        DownloadWebPageTask task = new DownloadWebPageTask();
        task.execute(params);        
    }          



    private class DownloadWebPageTask extends AsyncTask<String, Void, String> 
    {
        @Override
        protected String doInBackground(String... theParams) 
        {
            Log.d( "Inner class: " , "Doing stuff in background" );

            String myUrl = theParams[0];
            String myEmail = theParams[1];
            String myPassword = theParams[2];

            ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();  
            postParameters.add(new BasicNameValuePair("username", myEmail ));  
            postParameters.add(new BasicNameValuePair("password", myPassword ));            

            String response = "";
            for (String url : theParams) 
            {
                DefaultHttpClient client = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet(url);
                try 
                {
                    HttpResponse execute = client.execute(httpGet);
                    InputStream content = execute.getEntity().getContent();

                    BufferedReader buffer = new BufferedReader(
                            new InputStreamReader(content));
                    String s = "";
                    while ((s = buffer.readLine()) != null) {
                        response += s;
                    }

                } 
                catch (Exception e) 
                {
                    e.printStackTrace();
                }
            }
            return response;
        }


        @Override
        protected void onPostExecute(String result) 
        {
            Log.d( "Post execute: " , "In the post-execute method" );
            textView.setText(result);
        }    
    }

        public void readWebpage(View view) 
        {
            Log.d( "Read webpage: " , "In the read webpage method" );
            DownloadWebPageTask task = new DownloadWebPageTask();
            task.execute(new String[] { "http://www.problemio.com/auth/mobile_login.php" });
        }        
}

and I get this exception:

02-23 12:29:59.078: D/gralloc_goldfish(1799): Emulator without GPU emulation detected.
02-23 12:32:12.797: D/dalvikvm(1799): GC_CONCURRENT freed 204K, 4% free 9268K/9607K, paused 30ms+8ms
02-23 12:32:16.327: D/1(1799): 123
02-23 12:32:16.327: D/1(1799): hello
02-23 12:32:16.377: D/Inner class:(1799): Doing stuff in background
02-23 12:32:16.977: W/System.err(1799): java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=hello
02-23 12:32:16.977: W/System.err(1799):     at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:591)
02-23 12:32:16.987: W/System.err(1799):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:293)
02-23 12:32:16.987: W/System.err(1799):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
02-23 12:32:16.987: W/System.err(1799):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-23 12:32:16.998: W/System.err(1799):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
02-23 12:32:16.998: W/System.err(1799):     at com.problemio.LoginActivity$DownloadWebPageTask.doInBackground(LoginActivity.java:140)
02-23 12:32:17.007: W/System.err(1799):     at com.problemio.LoginActivity$DownloadWebPageTask.doInBackground(LoginActivity.java:1)
02-23 12:32:17.017: W/System.err(1799):     at android.os.AsyncTask$2.call(AsyncTask.java:264)
02-23 12:32:17.017: W/System.err(1799):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
02-23 12:32:17.017: W/System.err(1799):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
02-23 12:32:17.027: W/System.err(1799):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
02-23 12:32:17.037: W/System.err(1799):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
02-23 12:32:17.037: W/System.err(1799):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
02-23 12:32:17.037: W/System.err(1799):     at java.lang.Thread.run(Thread.java:856)
02-23 12:32:17.057: W/System.err(1799): java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=123
02-23 12:32:17.057: W/System.err(1799):     at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:591)
02-23 12:32:17.068: W/System.err(1799):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:293)
02-23 12:32:17.068: W/System.err(1799):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
02-23 12:32:17.068: W/System.err(1799):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-23 12:32:17.077: W/System.err(1799):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
02-23 12:32:17.077: W/System.err(1799):     at com.problemio.LoginActivity$DownloadWebPageTask.doInBackground(LoginActivity.java:140)
02-23 12:32:17.087: W/System.err(1799):     at com.problemio.LoginActivity$DownloadWebPageTask.doInBackground(LoginActivity.java:1)
02-23 12:32:17.087: W/System.err(1799):     at android.os.AsyncTask$2.call(AsyncTask.java:264)
02-23 12:32:17.087: W/System.err(1799):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
02-23 12:32:17.097: W/System.err(1799):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
02-23 12:32:17.097: W/System.err(1799):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
02-23 12:32:17.097: W/System.err(1799):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
02-23 12:32:17.107: W/System.err(1799):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
02-23 12:32:17.107: W/System.err(1799):     at java.lang.Thread.run(Thread.java:856)
02-23 12:32:17.107: D/Post execute:(1799): In the post-execute method
02-23 12:32:17.107: D/AndroidRuntime(1799): Shutting down VM
02-23 12:32:17.107: W/dalvikvm(1799): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
02-23 12:32:17.138: E/AndroidRuntime(1799): FATAL EXCEPTION: main
02-23 12:32:17.138: E/AndroidRuntime(1799): java.lang.NullPointerException
02-23 12:32:17.138: E/AndroidRuntime(1799):     at com.problemio.LoginActivity$DownloadWebPageTask.onPostExecute(LoginActivity.java:164)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at com.problemio.LoginActivity$DownloadWebPageTask.onPostExecute(LoginActivity.java:1)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at android.os.AsyncTask.finish(AsyncTask.java:602)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at android.os.AsyncTask.access$600(AsyncTask.java:156)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at android.os.Looper.loop(Looper.java:137)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at android.app.ActivityThread.main(ActivityThread.java:4424)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at java.lang.reflect.Method.invokeNative(Native Method)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at java.lang.reflect.Method.invoke(Method.java:511)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-23 12:32:17.138: E/AndroidRuntime(1799):     at dalvik.system.NativeStart.main(Native Method)
  • 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-30T10:05:26+00:00Added an answer on May 30, 2026 at 10:05 am

    Replace the for:

    for (String url : theParams) 
            {
                DefaultHttpClient client = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet(url);
    

    With this:

     DefaultHttpClient client = new DefaultHttpClient();
     HttpGet httpGet = new HttpGet(myUrl);
    

    Also, you’re not using the postParameters variable.

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

Sidebar

Related Questions

We have some code kicking around that uses this old internal Sun package for
I have this code in jQuery, that I want to reimplement with the prototype
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:
I have this code that performs an ajax call and loads the results into
I have this code #include <iostream> using namespace std; int main(int argc,char **argv) {
I have this code: CCalcArchive::CCalcArchive() : m_calcMap() { } m_calcMap is defined as this:
I have this code: myVariable which I want to change into trace(myVariable: + myVariable);
I have this code while($row = mysql_fetch_row($result)) { echo '<tr>'; $pk = $row[0]['ARTICLE_NO']; foreach($row
I have this code <?php session_start(); if (isset($_GET[cmd])) $cmd = $_GET[cmd]; else die(You should
I have this code, which works fine, but I would like to be able

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.