[Java for Android App Development] DeadDingo:
wait...

Here are snippets of my code to help debug.

[MENTION=439709]override[/MENTION]
public void onClick(View view) {

if(view.getId() == R.id.LoginButton) {

Toast.makeText(getApplicationContext(), "Attempting Connection", Toast.LENGTH_SHORT).show();

//Spawn new thread
new Thread(new Runnable() {
public void run() {
if(net.execLogin(mUserInput.getText().toString(), mPassInput.getText().toString())) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "Connected to Database", Toast.LENGTH_LONG).show();

}
});

//start new activity
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
[MENTION=439709]override[/MENTION]
public void run() {
Intent intent = new Intent(LoginActivity.this, ControlActivity.class);
startActivity(intent);
}
});

}
else {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "Connection Failed :(", Toast.LENGTH_LONG).show();
}
});
}

}

}).start();

}

}

And here is the new activity started by the above code:

package com.example.testapplication;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;

public class ControlActivity extends Activity implements View.OnClickListener {

private ArrayList<Hardware> list = new ArrayList<Hardware>();

EditText mEditText;
ListView mListView;

[MENTION=439709]override[/MENTION]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_control);

setupPage();
}
public void setupPage() {
Button search = (Button)findViewById(R.id.search);
search.setOnClickListener(this);
mEditText = (EditText)findViewById(R.id.editText);
mListView = (ListView)findViewById(R.id.listView);
}

[MENTION=439709]override[/MENTION]
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.control, menu);
return true;
}
public void onClick(View view) {

if(view.getId() == R.id.search) {

new Thread(new Runnable() {
public void run() {
list = new Networking().Search("Type", mEditText.getText().toString());
}
}).start();

ArrayAdapter<Hardware> adapter = new ArrayAdapter<Hardware>(this, android.R.layout.simple_list_item_1, list);
adapter.notifyDataSetChanged();

mListView.setAdapter(adapter);

if(list == null) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "0 Results Yielded :(", Toast.LENGTH_SHORT).show();
}
});
}
}

}

}

And here is the code I use to connect and query the database

import java.sql.*;
import java.util.*;

public class Networking implements DbQuery {

private static final String DRIVER = "org.mariadb.jdbc.Driver";
private static final String URL = "jdbc:mysql://146.187.16.32/Peirce";

ArrayList<Hardware> ara = new ArrayList<Hardware>();
Database db = new Database();
Hardware h1;

Connection con = null;
Statement stmt = null;

public boolean execLogin(String uName, String pWord) {

try {
Class.forName(DRIVER);
con = DriverManager.getConnection(URL, uName, pWord);
if(!con.isClosed()){
return true;
}
return false;
}catch(SQLException e) {
e.printStackTrace();
}catch(ClassNotFoundException e) {
e.printStackTrace();
}

return false;

}

public ArrayList<Hardware> Search(String arg, String target) {

try {
stmt = con.createStatement(); //throws null pointer exception
ResultSet rs = stmt.executeQuery("Select * from " + db.getTable() + " where " + arg + "='" + target + "';");
while(rs.next()) {
ara.add(new Hardware(rs.getString("Type"), rs.getString("Make"), rs.getString("Model"), rs.getString("Serial"), rs.getString("Comments")));
}
return ara;
}catch(SQLException e) {
e.printStackTrace();
}catch(NullPointerException e) {
e.printStackTrace();
}

return ara;

}