title: trouble connecting android app to localhost
body: <p>So I have connected my laptop to my androids wifi and used the gateway IP address however I am stuck trying to pull from the  database. The database works as I have tested it separately.<br>
  Logcat suggests  there's an error in login. (Ill Mark where the errors come up so you don't have to)  </p>
  
  <pre><code>07-31 01:49:41.323: W/System.err(20516):    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
  07-31 01:49:41.343: E/JSON Parser(20516): Error parsing data org.json.JSONException: End of input at character 0 of 
  07-31 01:49:41.353: D/request!(20516): starting
  07-31 01:49:41.353: W/dalvikvm(20516): threadid=11: thread exiting with uncaught exception (group=0x4194ada0)
  07-31 01:49:41.353: E/AndroidRuntime(20516): FATAL EXCEPTION: AsyncTask #1
  07-31 01:49:41.353: E/AndroidRuntime(20516): Process: com.example.mysqltest, PID: 20516
  07-31 01:49:41.353: E/AndroidRuntime(20516): java.lang.RuntimeException: An error occured while executing doInBackground()
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at android.os.AsyncTask$3.done(AsyncTask.java:300)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at java.lang.Thread.run(Thread.java:841)
  07-31 01:49:41.353: E/AndroidRuntime(20516): Caused by: java.lang.NullPointerException //this will be marked
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:125)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:1)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  07-31 01:49:41.353: E/AndroidRuntime(20516):    ... 4 more
  07-31 01:49:42.054: W/IInputConnectionWrapper(20516): showStatusIcon on inactive InputConnection
  07-31 01:49:42.474: E/WindowManager(20516): android.view.WindowLeaked: Activity com.example.mysqltest.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{42da7448 V.E..... R......D 0,0-1026,288} that was originally added here
  07-31 01:49:42.474: E/WindowManager(20516):     at android.view.ViewRootImpl.&lt;init&gt;(ViewRootImpl.java:457)
  07-31 01:49:42.474: E/WindowManager(20516):     at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:267)
  07-31 01:49:42.474: E/WindowManager(20516):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
  07-31 01:49:42.474: E/WindowManager(20516):     at android.app.Dialog.show(Dialog.java:288)
  07-31 01:49:42.474: E/WindowManager(20516):     at com.example.mysqltest.Login$AttemptLogin.onPreExecute(Login.java:103)  
  07-31 01:49:42.474: E/WindowManager(20516):     at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
  07-31 01:49:42.474: E/WindowManager(20516):     at android.os.AsyncTask.execute(AsyncTask.java:535)
  </code></pre>
  
  <p>package com.example.mysqltest;</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.http.NameValuePair;
  import org.apache.http.message.BasicNameValuePair;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.content.SharedPreferences.Editor;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.preference.PreferenceManager;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  public class Login extends Activity implements OnClickListener {
  
      private EditText user, pass;
      private Button mSubmit, mRegister;
  
      // Progress Dialog
      private ProgressDialog pDialog;
  
      // JSON parser class
      JSONParser jsonParser = new JSONParser();
  
      // php login script location:
  
      // localhost :
      // testing on your device
      // put your local ip instead, on windows, run CMD &gt; ipconfig
      // or in mac's terminal type ifconfig and look for the ip under en0 or en1
      // private static final String LOGIN_URL =
      // "http://xxx.xxx.x.x:1234/webservice/login.php";
  
      // testing on Emulator:
      private static final String LOGIN_URL = "http://192.168.43.1/drinkdealz/login.php";
  
      // testing from a real server:
      // private static final String LOGIN_URL =
      // "http://www.mybringback.com/webservice/login.php";
  
      // JSON element ids from repsonse of php script:
      private static final String TAG_SUCCESS = "success";
      private static final String TAG_MESSAGE = "message";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.login);
  
          // setup input fields
          user = (EditText) findViewById(R.id.username);
          pass = (EditText) findViewById(R.id.password);
  
          // setup buttons
          mSubmit = (Button) findViewById(R.id.login);
          mRegister = (Button) findViewById(R.id.register);
  
          // register listeners
          mSubmit.setOnClickListener(this);
          mRegister.setOnClickListener(this);
  
      }
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
          switch (v.getId()) {
          case R.id.login:
              new AttemptLogin().execute();
              break;
          case R.id.register:
              Intent i = new Intent(this, Register.class);
              startActivity(i);
              break;
  
          default:
              break;
          }
      }
  
      class AttemptLogin extends AsyncTask&lt;String, String, String&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              pDialog = new ProgressDialog(Login.this);
              pDialog.setMessage("Attempting login...");
              pDialog.setIndeterminate(false);
              pDialog.setCancelable(true);
              pDialog.show();
          }
  
          @Override
          protected String doInBackground(String... args) {
              // TODO Auto-generated method stub
              // Check for success tag
              int success;
              String username = user.getText().toString();
              String password = pass.getText().toString();
              try {
                  // Building Parameters
                  List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
                  params.add(new BasicNameValuePair("username", username));
                  params.add(new BasicNameValuePair("password", password));
  
                  Log.d("request!", "starting");
                  // getting product details by making HTTP request
                  JSONObject json = jsonParser.makeHttpRequest(LOGIN_URL, "POST",
                          params);
  
                  // check your log for json response
                  Log.d("Login attempt", json.toString());  ////THIS IS WHERE ERROR COMES UP////
  
                  // json success tag
                  success = json.getInt(TAG_SUCCESS);
                  if (success == 1) {
                      Log.d("Login Successful!", json.toString());
                      // save user data
                      SharedPreferences sp = PreferenceManager
                              .getDefaultSharedPreferences(Login.this);
                      Editor edit = sp.edit();
                      edit.putString("username", username);
                      edit.commit();
  
                      Intent i = new Intent(Login.this, ReadComments.class);
                      finish();
                      startActivity(i);
                      return json.getString(TAG_MESSAGE);
                  } else {
                      Log.d("Login Failure!", json.getString(TAG_MESSAGE));
                      return json.getString(TAG_MESSAGE);
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
              return null;
  
          }
  
          protected void onPostExecute(String file_url) {
              // dismiss the dialog once product deleted
              pDialog.dismiss();
              if (file_url != null) {
                  Toast.makeText(Login.this, file_url, Toast.LENGTH_LONG).show();
              }
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>Finally, sorry for excessive posting today, deadline approaching!<br>
  EDIT: I ran it again and got the error: 07-31 02:29:58.732: E/AndroidRuntime(26604): Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=192.168.43.1/drinkdealz/register.php</p>