Can someone help me with Android Login and Registration with PHP, MySQL and SQLite?
<p>Hi I created the files using the android hive example and I seem to be getting the following error I cannot figure out. My UI works fine its just whenever I click on the login button or the register button it forces a close plese help?</p>

<blockquote>
<pre><code>04-13 14:41:31.911: D/dalvikvm(431): GC_FOR_MALLOC freed 3881 objects / 200672 bytes in 88ms
04-13 14:41:32.110: E/JSON(431): &lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
04-13 14:41:32.110: E/JSON(431): &lt;html&gt;&lt;head&gt;
04-13 14:41:32.110: E/JSON(431): &lt;title&gt;404 Not Found&lt;/title&gt;
04-13 14:41:32.110: E/JSON(431): &lt;/head&gt;&lt;body&gt;
04-13 14:41:32.110: E/JSON(431): &lt;h1&gt;Not Found&lt;/h1&gt;
04-13 14:41:32.110: E/JSON(431): &lt;p&gt;The requested URL /android_login_api/ was not found on &gt;     this server.&lt;/p&gt;
04-13 14:41:32.110: E/JSON(431): &lt;/body&gt;&lt;/html&gt;
04-13 14:41:32.120: E/JSON Parser(431): Error parsing data org.json.JSONException: Value &lt;!&gt;     DOCTYPE of type java.lang.String cannot be converted to JSONObject
04-13 14:41:32.131: D/AndroidRuntime(431): Shutting down VM
04-13 14:41:32.131: W/dalvikvm(431): threadid=1: thread exiting with uncaught exception &gt;     &gt;     (group=0x4001d800)
04-13 14:41:32.131: E/AndroidRuntime(431): FATAL EXCEPTION: main
04-13 14:41:32.131: E/AndroidRuntime(431): java.lang.NullPointerException
04-13 14:41:32.131: E/AndroidRuntime(431):    at com.screenssample.LoginActivity$1.onClick&gt;     &gt;     (LoginActivity.java:59)
04-13 14:41:32.131: E/AndroidRuntime(431):    at android.view.View.performClick(View.java:2408)
04-13 14:41:32.131: E/AndroidRuntime(431):    at android.view.View$PerformClick.run&gt;     &gt;     &gt;     (View.java:8816)
04-13 14:41:32.131: E/AndroidRuntime(431):    at android.os.Handler.handleCallback&gt;     &gt;     &gt;     (Handler.java:587)
04-13 14:41:32.131: E/AndroidRuntime(431):    at android.os.Handler.dispatchMessage&gt;     &gt;     &gt;     (Handler.java:92)
04-13 14:41:32.131: E/AndroidRuntime(431):    at android.os.Looper.loop(Looper.java:123)
04-13 14:41:32.131: E/AndroidRuntime(431):    at android.app.ActivityThread.main&gt;     &gt;     &gt;     (ActivityThread.java:4627)
04-13 14:41:32.131: E/AndroidRuntime(431):    at java.lang.reflect.Method.invokeNative(Native &gt;     Method)
04-13 14:41:32.131: E/AndroidRuntime(431):    at java.lang.reflect.Method.invoke&gt;     &gt;     &gt;     (Method.java:521)
04-13 14:41:32.131: E/AndroidRuntime(431):    at om.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-13 14:41:32.131: E/AndroidRuntime(431):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-13 14:41:32.131: E/AndroidRuntime(431):    at dalvik.system.NativeStart.main(Native Method)
</code></pre>
</blockquote>

<p>The LoginActivity code reads </p>

<p>package com.screenssample; </p>

<blockquote>
<pre><code>import java.util.HashMap; 

import org.json.JSONException; 
import org.json.JSONObject; 

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

import com.screenssample.DatabaseHandler; 
import com.screenssample.UserFunctions; 

public class LoginActivity extends Activity { 
    Button btnLogin; 
    Button btnLinkToRegister; 
    EditText inputEmail; 
    EditText inputPassword; 
   TextView loginErrorMsg; 
</code></pre>
</blockquote>

<pre><code>// JSON Response node names 
private static String KEY_SUCCESS = "success"; 
private static String KEY_ERROR = "error"; 
private static String KEY_ERROR_MSG = "error_msg"; 
private static String KEY_UID = "uid"; 
private static String KEY_NAME = "name"; 
private static String KEY_EMAIL = "email"; 
private static String KEY_CREATED_AT = "created_at"; 

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

    // Importing all assets like buttons, text fields 
    inputEmail = (EditText) findViewById(R.id.loginEmail); 
    inputPassword = (EditText) findViewById(R.id.loginPassword); 
    btnLogin = (Button) findViewById(R.id.btnLogin); 
    btnLinkToRegister = (Button) findViewById(R.id.btnLinkToRegisterScreen); 
    loginErrorMsg = (TextView) findViewById(R.id.login_error); 

    // Login button Click Event 
    btnLogin.setOnClickListener(new View.OnClickListener() { 

        public void onClick(View view) { 
            String email = inputEmail.getText().toString(); 
            String password = inputPassword.getText().toString(); 
            UserFunctions userFunction = new UserFunctions(); 
            JSONObject json = userFunction.loginUser(email, password); 

            // check for login response 
            try { 
                if (json.getString(KEY_SUCCESS) != null) { 
                    loginErrorMsg.setText(""); 
                    String res = json.getString(KEY_SUCCESS); 
                    if(Integer.parseInt(res) == 1){ 
                        // user successfully logged in 
                        // Store user details in SQLite Database 
                        DatabaseHandler db = new DatabaseHandler(getApplicationContext()); 
                        JSONObject json_user = json.getJSONObject("user"); 

                        // Clear all previous data in database 
                        userFunction.logoutUser(getApplicationContext()); 
                        db.addUser(json_user.getString(KEY_NAME), json_user.getString(KEY_EMAIL), json.getString(KEY_UID), json_user.getString(KEY_CREATED_AT));                         

                        // Launch Dashboard Screen 
                        Intent dashboard = new Intent(getApplicationContext(), DashboardActivity.class); 

                        // Close all views before launching Dashboard 
                        dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
                        startActivity(dashboard); 

                        // Close Login Screen 
                        finish(); 
                    }else{ 
                        // Error in login 
                        loginErrorMsg.setText("Incorrect username/password"); 
                    } 
                } 
            } catch (JSONException e) { 
                e.printStackTrace(); 
            } 
        } 
    }); 

    // Link to Register Screen 
    btnLinkToRegister.setOnClickListener(new View.OnClickListener() { 

        public void onClick(View view) { 
            Intent i = new Intent(getApplicationContext(), 
                    RegisterActivity.class); 
            startActivity(i); 
            finish(); 
        } 
    }); 
} 
</code></pre>

<p>}</p>
